4 Replies Latest reply on Nov 30, 2015 10:22 AM by creditunion123

    execute menu item

    creditunion123 Level 1

      I have scripting inside an app toolbar that staff press to automatically extract pages and email them to clients.

      Issue is some emails are blocking the file due to the javascript.  I am looking to remove the javascript from the extracted pages prior to email.  I want my script to do it - to make it easy for staff

       

      I have my system set up to remove hidden items when emailed and when I hit File Send File this works well - the function comes up to complete but the script that emails the doc does not trigger this. If I put app.execmenueitem("Email") in the console it works.  I wanted to put in an app.execmenuitem in my script. Can I do this.

       

      This is what I have so far

       

      Created Trusted Function to make sure I could call the menu item

      myEmail = app.trustPropagatorFunction(function(doc,path)

                    {

                     app.beginPriv();

                     doc.Email(path);

                     app.endPriv();

                     })

                     myTrustedSpecialEmailFunc = app.trustedFunction(function(doc,path)

                     {

                     // Privileged and/or non-privileged code above

                     app.beginPriv();

                     myEmail(doc,path);

                     app.endPriv();

                     // Privileged and/or non-privileged code below

                     });

       

      Then in my button I have the following

       

      myTrustedSpecialEmailFunc(this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody});

       

      it emails the documents fine BUT does not call the pop up so I can remove hidden items prior to sending

        • 1. Re: execute menu item
          gkaiseril MVP & Adobe Community Professional

          I see no indication of a pop-up.

           

          You need to know that the list of actions for any field are not synchronous, that is they do not wait until a prior item in the list finishes before firing the next action. If you need them to be synchronous then you need to combine them into one long script and add control statements to trap errors if needed.

          • 2. Re: execute menu item
            creditunion123 Level 1

            I Do have the MyTrustedEmailFunction as part of a long script.  The script, once the button is pushed, runs thru and extracts the first three pages and saves them to a folder, then deletes.  It then executes a pop up question asking if the person wants terms and contitions printed or emailed.  If email ticked it extracts the last 19 pages to email.  This is where I want the app.execMenuItem("Email") to come in so staff can tick the button to remove hidden items before creating the actual email. From the trusted function.  I can post my entire script here if it would help

             

            or if I try to create an action, can I place that action in a simple click here for the staff. 

            • 3. Re: execute menu item
              gkaiseril MVP & Adobe Community Professional

              If you want an analysis of your script, we need to see the entire script and since many form fields and their scripts interact with each other, maybe a link to the form or a sample form with the same issue.

               

              You might have problems with such a large form with slower computers, systems  not on the local network or mobile devices.

              • 4. Re: execute menu item
                creditunion123 Level 1


                Here is my entire script in the button that staff press

                 

                // create the function I want executed when pressed

                function cButtJS() {
                //step 1 - extract internal use document and the risk ranking - save to folder- delete from application

                var name = this.getField("FormValues.accountNames_0").value
                var folio =this.getField("FormValues.folioNumber_0").value

                var oNewDoc = this.extractPages(0,3);
                myTrustedSpecialSaveFunc(oNewDoc, "/HO-VM-SARUMAN/WorkSpaces/Public Folders/AccountOpening/Internal/" +"Account Agreement "+name + " " +folio +".pdf");
                oNewDoc.closeDoc(true);

                this.deletePages(0);
                var Replace =
                {

                    result:"cancel",
                    DoDialog: function(){return app.execDialog(this);},
                    bChk1:false,
                    bChk2:false,
                    initialize: function(dialog)
                    {
                        var dlgInit =
                        {
                                "Chk1": this.bChk1,
                                "Chk2": this.bChk2,
                               
                        };
                        dialog.load(dlgInit);
                    },
                    commit: function(dialog)
                    {
                        var oRslt = dialog.store();
                        this.bChk1 = oRslt["Chk1"];
                        this.bChk2 = oRslt["Chk2"];
                      
                    },
                    description:
                    {
                        name: "Replace",
                        elements:
                        [
                            {
                                type: "view",
                                elements:
                                [
                                    {
                                        type: "view",
                                        char_height: 10,
                                        elements:
                                        [
                                            {
                                                type: "static_text",
                                                item_id: "stat",
                                                name: "Would you like the terms and conditions emailed to you or would you like printed copies today?",
                                                char_width: 15,
                                                alignment: "align_fill",
                                                font: "dialog",
                                            },
                                            {
                                                type: "view",
                                                char_width: 8,
                                                char_height: 8,
                                                align_children: "align_top",
                                                elements:
                                                [
                                                    {
                                                        type: "view",
                                                        char_width: 8,
                                                        char_height: 8,
                                                        elements:
                                                        [

                        {
                                                                type: "check_box",
                                                                item_id: "Chk1",
                                                                name: "Email",
                                                            },
                                                           {
                                                                type: "check_box",
                                                                item_id: "Chk2",
                                                                name: "Printed",
                                                            },
                                                                                                      
                                                        ]
                                                    },
                                                   
                                                ]
                                            },
                                        ]
                                    },
                                    {
                                        type: "ok_cancel",
                                    },
                                ]
                            },
                        ]
                    }
                };

                Replace.bChk1 = false;
                Replace.bChk2 = false;

                if ("ok" == Replace.DoDialog()) {

                if (Replace.bChk1) {// if yes - email docs, extract terms and email, then print application

                var Email = this.getField("FormValues.emailAddress_0").value
                var staff = this.getField("FormValues.Staff").value

                 
                if (Email==""){

                var cEmailresponse = app.response ({
                            cQuestion:"Enter the Member's email address.  Enter in in the banking system as well for future use",
                            cTitle:"Email Address",
                            bPassword:false,
                            cDefault: "",
                            cLabel:"Email Address"
                });

                        if(cEmailresponse && cEmailresponse.length) {
                        getField("FormValues.emailAddress_0").value = cEmailresponse
                }
                }
                this.getField("Emailed Docs").value = "Emailed Terms and Conditions"
                var email = this.getField("FormValues.emailAddress_0").value
                var email2 = this.getField("FormValues.emailAddress_1").value
                var email3 = this.getField("FormValues.emailAddress_2").value


                var cSubLine = " Credit Union Membership Terms and Conditions";

                var cBody = "Please find attached important information regarding the terms and conditions of your account with Ixxxx. These forms contain information on protecting your privacy, features of MemberDirect Online Banking and the responsibilities of both Ixxxx and you, the member for protecting your online data.  We have also attached a link to a number of YouTube videos." + "\n\n" + "These videos go over some of the features offered by our Online Banking as well as ways to protect your online data.  Simply copy the link below and paste in the address or search bar of you internet browser" +"\n\n" + " https://www.youtube.com/channel/UCQiDrmS2WeGP_HmEeD652EA" +"\n\n" +"Thank you for choosing xxxxxx Credit Union."+"\n\n" +staff;

                var cToAddr = email +";" + email2 +";" + email3;
                //var cCCAddr = email +";" + email2 +";" + email3;
                //var name = this.getField("FormValues.accountNames_0").value
                //var folio =this.getField("FormValues.folioNumber_0").value

                this.getTemplate("Terms22").hidden=true;
                this.getTemplate("Terms2").hidden=true;
                this.getTemplate("Terms10").hidden=true;

                 

                //     HERE IS MY SCRIPT TO EXTRACT THE TERMS.  I WANT THEM TO BE EMAILED BUT BEFORE I EMAIL THEM I WANT THE POP UP FOR HIDDEN FILES TO COME UP AND REMOVE THE JAVASCRIPT.  THE POP UP IS NOT GENERTED BY CODE BUT BY SETTINGS IN THE PREFERENCES..  IF I GO FILE > SEND FILE - THE HIDDEN FILE POP UP APPEARS.  IF THE EMAIL IS GENERATED BY CODE THE HIDDEN FILE POP UP DOES NOT HAPPEN

                 

                 

                var oNewDoc = this.extractPages(this.numPages-19, this.numPages-1);

                myTrustedSpecialEmailFunc(oNewDoc.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody}));


                myTrustedSpecialSaveFunc(oNewDoc, "/HO-VM-SARUMAN/WorkSpaces/Public Folders/AccountOpening/TermsandConditions/" +"Account Agreement "+name + " " +folio +".pdf");

                oNewDoc.submitForm({
                     cURL: cEmailURL,
                     cSubmitAs:"PDF",
                     cCharSet:"utf-8"});

                oNewDoc.closeDoc(true);

                this.deletePages(this.numPages-19, this.numPages-1);


                print({
                bUI: true,
                bSilent: true,
                bShrinkToFit: true,
                });



                 
                }

                if (Replace.bChk2) {// just print the whole application
                this.getField("Emailed Docs").value = "Printed Terms and Conditions and handed to Member"

                 


                print({
                bUI: true,
                bSilent: true,
                bShrinkToFit: true,
                });
                this.deletePages(this.numPages-22, this.numPages-1);
                }
                }

                var name = this.getField("FormValues.accountNames_0").value
                var folio =this.getField("FormValues.folioNumber_0").value

                myTrustedSpecialSaveFunc(this, "/HO-VM-SARUMAN/WorkSpaces/Public Folders/AccountOpening/"+name + " " +folio +".pdf");
                }
                // enable button

                app.addToolButton({cName:"Print Personal Membership Package", cLabel:"CLICK HERE to Print Personal Membership Package", cTooltext:"", cExec:"cButtJS(event.target)"});