Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Using JS to create a stamp getting undefined error on one of the input field

New Here ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

Hi I've been using this code with 4 input field (AFE,LOCATION,CODING,AMOUNT) for a stamp and it was working all fine. I then needed to add one more field (CC) and now I'm always getting UNDEFINED on my new added field called "CC1" in the code but the other fields are still populating properly. Any help would be greatly appreciated.
Screenshot 2021-06-23 162757.png

 

//Acrobat JavaScript Dialog
//Created by AcroDialogs from WindJack Solutions

////*******************************************
//// 
////   Code for applying data to the stamp is at bottom of page
////
////*******************************************


// Dialog for entering stamp data
var DesignChangeInfo =
{

    result:"cancel",
    DoDialog: function(){return app.execDialog(this);},
    bExtConsultant:false,
    strStatus:"",
    strDate:"",
    strCC1:"",
    strAFE1:"",
    strLOC1:"",
    strCOD1:"",
    strAMT1:"",


    GetRadioSel:function(oRslts,aCtrls){
      for(var strRtn=aCtrls[0];aCtrls.length>0;strRtn=aCtrls.pop()){
        if(oRslts[strRtn] == true)
          return strRtn;
      }
      return "";
    },
    initialize: function(dialog)
    {
        var dlgInit = 
        {
                "ExCn": this.bExtConsultant,
                "CDat": this.strDate,
                "CC1": this.strCC1,
             
                "AFE1": this.strAFE1,
              
                "LOC1": this.strLOC1,
              
                "COD1": this.strCOD1,
               
                "AMT1": this.strAMT1,
                

        };
        dlgInit[this.strStatus] = true;
        dialog.load(dlgInit);
    },
    commit: function(dialog)
    {
        var oRslt = dialog.store();
        this.bExtConsultant = oRslt["ExCn"];
        this.strStatus = this.GetRadioSel(oRslt,["Prop","Revd","Appr","Rejd"]);
        this.strDate = oRslt["CDat"];
        this.strCC1 = oRslt["CC1"];
     
        this.strAFE1 = oRslt["AFE1"];
   
        this.strLOC1 = oRslt["LOC1"];
      
        this.strCOD1 = oRslt["COD1"];
     
        this.strAMT1 = oRslt["AMT1"];
        

    },





   //////////////////////////////// Column 0 ///////////////////////////////////////////////////

    description:
    {name: "Invoice",
      elements:
      [{type: "view",
        elements:
          [{type: "view",
            elements:



///////////////////////// Title //////////////////////////////

              [{type: "static_text",
                 item_id: "stat",
                 name: "Coding",
                 char_width: 15,
                 alignment: "align_fill",
                 font: "palette",
                 bold: true,
                            },

///////////////////////// Date ////////////////////////////// 

                  {type: "view",
                    align_children: "align_top",
                    alignment: "align_fill",
                    elements:
                    [{type: "static_text",
                            item_id: "stat",
                            name: "Date:",
                            width: 72,
                            alignment: "align_right",
                            font: "dialog",
                        },
                      {type: "edit_text",
                        item_id: "CDat",
                        variable_Name: "strDate",
                        char_width: 15,
                        },
                      ]
                },


///////////////////////// Box and 4 Radio Button //////////////////////////////      this.GetRadioSel(oRslt,["Prop","Revd","Appr","Rejd"]);                      
                            
                            {type: "view",
                              char_width: 8,
                              char_height: 8,
                              align_children: "align_top",
                              elements:
                              [{type: "cluster",
                                        item_id: "cls1",
                                        name: "Activity",
                                        char_width: 8,
                                        char_height: 8,
                                        elements:
                                        [{type: "radio",
                                                item_id: "Prop",
                                                group_id: "Stat",
                                                name: "Opex",
                                                variable_Name: "strStatus",
                                            },
                                            {
                                                type: "radio",
                                                item_id: "Revd",
                                                group_id: "Stat",
                                                name: "Equipment",
                                            },
                                            {
                                                type: "radio",
                                                item_id: "Rejd",
                                                group_id: "Stat",
                                                name: "Tie-In ",
                                            },
                                            {
                                                type: "radio",
                                                item_id: "Appr",
                                                group_id: "Stat",
                                                name: "Facilities",
                                            },]},


                     


//////////////////////////////// Column 1 Row1 ///////////////////////////////////////////////////
//////////////////////////////// Column 1 Row1 ///////////////////////////////////////////////////
//////////////////////////////// Column 1 Row1 ///////////////////////////////////////////////////



                                    
                                    {
                                        type: "view",
                                        elements:
                                        [{type: "view",
                                            align_children: "align_top",
                                            alignment: "align_fill",
                                            elements:
                                                [
                                                    {type: "static_text",
                                                      item_id: "sta0",
                                                      name: "CC #1:",
                                                      width: 55,
                                                      alignment: "align_right",
                                                      font: "dialog",
                                                    },
                                                    {type: "edit_text",
                                                      item_id: "CC1",
                                                      variable_Name: "strCC1",
                                                      char_width: 12,
                                                       alignment: "align_fill",
                                                      },
                                                  ]
                                            },






//////////////////////////////// END OF COLUMN 1  ///////////////////////////////////////////////////
                                      
                                         ]
                                    },



//////////////////////////////// Column 2 Row1 ///////////////////////////////////////////////////
//////////////////////////////// Column 2 Row1 ///////////////////////////////////////////////////
//////////////////////////////// Column 2 Row1 ///////////////////////////////////////////////////



                                    
                                    {
                                        type: "view",
                                        elements:
                                        [{type: "view",
                                            align_children: "align_top",
                                            alignment: "align_fill",
                                            elements:
                                                [
                                                    {type: "static_text",
                                                      item_id: "sta1",
                                                      name: "AFE #1:",
                                                      width: 55,
                                                      alignment: "align_right",
                                                      font: "dialog",
                                                    },
                                                    {type: "edit_text",
                                                      item_id: "AFE1",
                                                      variable_Name: "strAFE1",
                                                      char_width: 12,
                                                       alignment: "align_fill",
                                                      },
                                                  ]
                                            },


                                      
                                         ]
                                    },



//////////////////////////////// Column 3 Row 1 LOCATION 1 ///////////////////////////////////////////////////
                                           
                                           
                                           {
                                        type: "view",
                                        elements:
                                        [
                                           
                                           
                                           
                                            {
                                                type: "view",
                                                align_children: "align_top",
                                                elements:
                                                [
                                                    {
                                                        type: "static_text",
                                                        item_id: "sta2",
                                                        name: "LOC #1:",
                                                        width: 55,
                                                        alignment: "align_right",
                                                        font: "dialog",
                                                    },
                                                    {
                                                        type: "edit_text",
                                                        item_id: "LOC1",
                                                        variable_Name: "strLOC1",
                                                        char_width: 12,
                                                        alignment: "align_fill",
                                                    },
                                                ]
                                            },




                                  ]
                                    },

////////////////////////////////////////////////////////////////////////////////////////////////////                                    



//////////////////////////////// Column 4 Row 1 CODING 1 ///////////////////////////////////////////////////
                                           
                                           
                                           {
                                        type: "view",
                                        elements:
                                        [
                                           
                                           
                                           
                                            {
                                                type: "view",
                                                align_children: "align_top",
                                                elements:
                                                [
                                                    {
                                                        type: "static_text",
                                                        item_id: "sta3",
                                                        name: "COD #1:",
                                                        width: 55,
                                                        alignment: "align_right",
                                                        font: "dialog",
                                                    },
                                                    {
                                                        type: "edit_text",
                                                        item_id: "COD1",
                                                        variable_Name: "strCOD1",
                                                        char_width: 12,
                                                        alignment: "align_fill",
                                                    },
                                                ]
                                            },


                                   
                                    
                                    ]
                                    },                                    

////////////////////////////////////////////////////////////////////////////////////////////////////






//////////////////////////////// Column 5 Row 1 AMOUNT 1 ///////////////////////////////////////////////////
                                           
                                           
                                           {
                                        type: "view",
                                        elements:
                                        [
                                           
                                           
                                           
                                            {
                                                type: "view",
                                                align_children: "align_top",
                                                elements:
                                                [
                                                    {
                                                        type: "static_text",
                                                        item_id: "sta4",
                                                        name: "AMT #1:",
                                                        width: 55,
                                                        alignment: "align_right",
                                                        font: "dialog",
                                                    },
                                                    {
                                                        type: "edit_text",
                                                        item_id: "AMT1",
                                                        variable_Name: "strAMT1",
                                                        char_width: 12,
                                                        alignment: "align_fill",
                                                    },
                                                ]
                                            },


                                   
                                    
                                    ]
                                    },                                    

////////////////////////////////////////////////////////////////////////////////////////////////////



                                ]
                                
                            },
                        ]
                    },
                    {
                        type: "ok",
                    },
                ]
            },
        ]
    }
};

////*******************************************
//// 
////   Code that applies data to stamp
////
////*******************************************

if(event.source.forReal && (event.source.stampName == "#MhucqD7H18s9ADaKAQY4xD"))
{
   //  All data, except for the date and status
   //  are saved at the app level so that it can be reused
   
   DesignChangeInfo.strDate = util.printd("mm/dd/yyyy",new Date());
   DesignChangeInfo.strStatus = "";
  
   try{ 
     if(app.media.bExtConsultant)
       DesignChangeInfo.bExtConsultant = app.media.bExtConsultant;
   }catch(e){
     app.media.bExtConsultant = false;
   }
if(app.media.strCC1)
     DesignChangeInfo.strCC1 = app.media.strCC1;

if(app.media.strAFE1)
     DesignChangeInfo.strAFE1 = app.media.strAFE1;

if(app.media.strLOC1)
     DesignChangeInfo.strLOC1 = app.media.strLOC1;



if(app.media.strCOD1)
     DesignChangeInfo.strCOD1 = app.media.strCOD1;

if(app.media.strAMT1)
     DesignChangeInfo.strAMT1 = app.media.strAMT1;


if("ok" == DesignChangeInfo.DoDialog())
   {
   
       event.value = DesignChangeInfo.strDate;
      //  this.getField("ExternalConsult").checkThisBox(0,DesignChangeInfo.bExtConsultant,0);
       this.getField("CC1").value = DesignChangeInfo.strCC1;
  
       this.getField("AFE1").value = DesignChangeInfo.strAFE1;
     
       this.getField("LOC1").value = DesignChangeInfo.strLOC1;
     
       this.getField("COD1").value = DesignChangeInfo.strCOD1;
      
       this.getField("AMT1").value = DesignChangeInfo.strAMT1;
      
 
   
       this.getField("State").value = DesignChangeInfo.strStatus;
   
       // Save Current Values
       app.media.bExtConsultant = DesignChangeInfo.bExtConsultant;
       app.media.strCC1 = DesignChangeInfo.strCC1;
    
       app.media.strAFE1 = DesignChangeInfo.strAFE1;
  
       app.media.strLOC1 = DesignChangeInfo.strLOC1;
   
       app.media.strCOD1 = DesignChangeInfo.strCOD1;
     
       app.media.strAMT1 = DesignChangeInfo.strAMT1;
      

   }
   
} 

 

 

TOPICS
JavaScript, PDF forms

Views

146

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jun 24, 2021 Jun 24, 2021
Following does not work: {type: "edit_text", item_id: "CC1", variable_Name: "strCC1", char_width: 12, alignment: "align_fill", }, The id must be 4 chars.

Likes

Translate

Translate
Adobe Community Professional ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

Following does not work:


{type: "edit_text",
item_id: "CC1",
variable_Name: "strCC1",
char_width: 12,
alignment: "align_fill",
},

 

The id must be 4 chars.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

LATEST
Thank you for your answer now it works that was the issue

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines