Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JavaScript dialog box help, variable returning as undefined

New Here ,
Sep 17, 2024 Sep 17, 2024

I have a folder level script that will send a form to specific emails depending of which check boxes are selected. Sometime the forms have fillable fields and other times the form is flatten and emailed for us to review. When the form is flattened i have created a dialog box that will allow the agents to enter the case number and then select which emails it will need to be sent to. 

 

It is able to to send it to the correct emails depending on which checkboxes are marked off but the case number is returning as undefined in the subject line of the email.

 

I am sure i have many redundancies and the code can be a bit more streamlined. The version I posted is one where I have changed a few things already in hopes to resolve the issue. Everything work in all other aspects except recieving the case number in the dialog box and returning it on the subject line of the email when sent. 

 

// Emailing SRFs
var SRFSend = app.trustedFunction(function(){

    if ( this.getField("Check Box1") === null){
        // Dialog Definition
        var SRFDlg ={
            
            DoDialog: function(){
                return app.execDialog(this)
            },

            SRFAcc: "",
            initialize: function(dialog)
            {
                var DiagInit = {
                    "SRFAcce":this.SRFAcc,
                }; 
                dialog.load(DiagInit);
            },

            commit: function(dialog)
            {
                var SRFdata = dialog.store();
                var tickedItems = [];
                if (SRFdata["pCK1"])
                    tickedItems.push("email address");
                if (SRFdata["pCK2"])
                    tickedItems.push("email address");
                if (SRFdata["pCK3"])
                    tickedItems.push("email address");
                this.SRFdata = tickedItems.join(";");
                var SRFDAcc = dialog.store();
                this.SRFAcc = SRFDAcc["SRFAcce"];
            },

            description:
            {
                name: "Complete Entry",
                elements:
                [
                    {
                        type: "view",
                        elements:
                        [
                            {
                                name: "Accession",
                                type: "static_text",
                            },
                            {
                                item_id: "SRFAcce",
                                type: "edit_text",
                                char_width: 15
                            },
                            {
                                name: "Select the Correct Department",
                                type: "static_text",
                            },
                            {
                                name: "Dept 1",
                                type: "check_box",
                                item_id: "pCK1",
                            },
                            {
                                name: "Dept 2",
                                type: "check_box",
                                item_id: "pCK2",
                            },
                            {
                                name: "Dept 3",
                                type: "check_box",
                                item_id: "pCK3",
                            },
                            {
                                type: "ok_cancel",
                            },
                        ]
                    },
                ]
            }
        };

        if("ok" == SRFDlg.DoDialog()){
            var SRFAccession = SRFDlg.SRFAcc;
            var SRFEmail = SRFDlg.SRFdata;
            SRFSubLine = "SRF for " + SRFAccession;
            //emailing the doc
            this.mailDoc({bUI: true, cTo: SRFEmail, cSubject: SRFSubLine});
        }
        
    }else {
        // setting all the variables 
        var SRFAccession = this.getField("Accession Number").value;
        var SRFEmail = "";
        var SRFSubLine = "SRF for " + SRFAccession;
        var cCK1 = this.getField("Check Box1").valueAsString;
        var cCK2 = this.getField("Check Box2").valueAsString;
        var cCK3 = this.getField("Check Box3").valueAsString;
    
        if(cCK1 === null && cCK2 === null && cCK3 === null){
            SRFEmail = "email address;";
        }else (cCK1 > 0 || cCK2 > 0 || cCK3 > 0);{
            if(cCK1 != "Off")
            SRFEmail = "email adress;";
            if(cCK2 != "Off")
            SRFEmail += "email address;";
            if(cCK3 != "Off")
            SRFEmail += "email address;";
        }
        //emailing the doc
        this.mailDoc({bUI: true, cTo: SRFEmail, cSubject: SRFSubLine});
    }
  
//    this.closeDoc(true);
});

 

 

TOPICS
JavaScript , PDF , PDF forms
691
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Sep 17, 2024 Sep 17, 2024

For item_id are only 4 characters allowed.

View solution in original post

Translate
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
Community Expert ,
Sep 17, 2024 Sep 17, 2024

For item_id are only 4 characters allowed.

Translate
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 ,
Sep 17, 2024 Sep 17, 2024
LATEST

Thank you! that resolved the problem.  

Translate
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