4 Replies Latest reply on Nov 25, 2014 2:19 AM by try67

    Looking to execute javascript code if a template is hidden

    creditunion123 Level 1


      I have a form I am working on that I want a dialogue box to pop up if certain criteria are met:

      1.Name field is blank

      2. Type field is NOT blank

      3 A template is not hidden

       

      All three must be in play for the code to run.

      I have two issues

       

      1.  the code to say if the template is hidden actually unhides templates rather than just look to see if the statement is true

      2. The pop up does not happen with the template information - but does if I only have the other two parameters

       

      var indem1 = this.getField("FormValues.accountNames_1").value
      var IndemType = this.getField("IndemType").value

       

      if I put in:

      if ((getTemplate("INDA1).hidden = false) || (getTemplate(INDS1").hidden = false) && (IndemType !=="") &&(indem1 ==="")){ the two templates become visible and I dont want them to become visible - just want the code to run IF they are not hidden

       

      The code below without the template stuff does work to bring up the dialogue box

       

      if ((IndemType !=="") &&(indem1 ==="")){


      var RepInfoDlg =
            {
         
              DoDialog: function()
              {
                return app.execDialog(RepInfoDlg);
              },
              strNam1:"",
              strAdd1:"",
             
             
              initialize: function(dialog)
              {
                this.result = "Cancel";
                dialog.load(
                  {
                    "RNam1": this.strNam1,
                    "RAdd1": this.strAdd1,
                   
                    "sta3": "The Name and Address of an Indemnitor is blank.  Please enter the required information" //  You have the following indemnitors already on the forms" + "\n\n" + indem1 + "\n" + indem2 + "\n" + indem3+ "\n" + indem4  + "\n" + indem5 + "\n" + indem6 + "\n" + indem8+ "\n" + indem9  + "\n" + indem10
                 }
                );
         
         
         
              },
              validate: function(dialog)
              {
          var rslt = dialog.store();
                var bRtn = (rslt["RNam1"].length != 0) && (rslt["RAdd1"].length != 0);
                if(!bRtn) app.alert("Please enter detailed information regarding the missing Indemnitor");
                return bRtn;
              },
              commit: function(dialog)
              {
          var rslt = dialog.store();
          this.strNam1 = rslt["RNam1"];
          this.strNam1 = rslt["RAdd1"];
         
          },
              description:
              {
                name: "Rep Info",
                elements:
                [
                  {
                    type: "view",
                    elements:
                    [
                      {
                        align_children: "align_left",
                        type: "view",
                        elements:
                        [
                          {
                            type: "view",
                            elements:
                            [
                              {
                                alignment: "align_fill",
                                font: "dialog",
                                item_id: "stat",
                                name: "Name of Indemnitor",
                                type: "static_text",
                              },
                              {
                                char_width: 8,
                                height: 30,
                                item_id: "RNam1",
                                type: "edit_text",
                                width: 320,
                              },
                            ]
                          },
                          {
                            type: "view",
                            elements:
                            [
                              {
                                item_id: "sta1",
                                name: "Address of Indemnitor",
                                type: "static_text",
                              },
                              {
                                height: 30,
                                item_id: "RAdd1",
                                type: "edit_text",
                                width: 320,
              multiline: true
                              },
                            ]
                          },
                        
                      {
                        item_id: "sta3",
                         type: "static_text",
                        char_height: 10,
                        char_width: 60,
            //            multiline: true,
                      },
                      {
                        align_children: "align_fill",
                        type: "ok_cancel",
                      },
                    ]
                  },
                ]
              }
        ]
            }
      };
        
              if(RepInfoDlg.DoDialog() == "ok"){

      this.getField("FormValues.accountNames_1").value = RepInfoDlg.strNam1
      this.getField("FormValues.homeAddress_1").value = RepInfoDlg.strAdd1

      }
      }