Skip to main content
Known Participant
August 7, 2019
Question

submit button JavaScript

  • August 7, 2019
  • 2 replies
  • 726 views

hi, i have found bellow code & edited but it's not working. can u pls help me to correct submit button JavaScript. i'm using adobe pro DC. thanks..

var myDoc = event.target;

try {

    myDoc.mailDoc({

        bUI: false,

        cTo: 'sbartholow@ppbi.com',

        cCc: 'khall@ppbi.com',

        cSubject: 'New Employee Form - '+EmpName+ " - " + StrtDate+ " - " + Loc,

        cSubmitAs: "PDF",

        cMsg: cBody

    });

} catch (e) {

 

}

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
August 8, 2019

Try this:

var myDoc = event.target;

try {

    myDoc.mailDoc({

        bUI: false,

        cTo: 'sbartholow@ppbi.com',

        cCc: 'khall@ppbi.com',

        cSubject: 'New Employee Form - '+EmpName+ " - " + StrtDate+ " - " + Loc,

        cSubmitAs: "PDF",

        cMsg: cBody

    });

} catch (e) {

     console.show();

     console.println(e);

}

try67
Community Expert
Community Expert
August 7, 2019

"Not working" how, exactly?
And why did you add a try-catch clause and then not even print out the contents of the caught error? You've made it almost impossible to know what went wrong with your code.

Remove that and try again.

Oh, and also remove the bUI parameter. It won't work. The UI will be displayed and the user will have to manually send the email.

omanbuxAuthor
Known Participant
August 8, 2019

hi, i'm really sorry i have done wrong. actually bellow code add to submit button in livecycle form. so i want to add same code into my form but i'm making my form using adobe pro DC. can u pls help me to convert bellow submit code that work in adobe pro ??. thanks..

form1.Page1.E-mailButton::click - (JavaScript, client)

//+ GENERATED - DO NOT EDIT (ID:F0343AD4-256A-4447-B553-B26FB0EBFD0B CRC:2547463463)

//+ Type: Action

//+ Result4: SetEnabled("$Node4","readOnly")

//+ Result3: SetPresence("$Node3","hidden")

//+ Result2: SetPresence("$Node2","visible")

//+ Result1: SetFieldValue("$Node2","tovalueof","$Node3")

//+ Node4: form1[0].Page1[0]

//+ Node3: form1[0].Page1[0].CurrentDate[0]

//+ Node2: form1[0].Page1[0].SubmittedON[0]

//+ Node1: form1[0].Page1[0].E-mailButton[0]

//+ Condition1: Button("$Node1","click")

//+ ActionName: E-mailButton.click

this.resolveNode("SubmittedON").rawValue = this.resolveNode("CurrentDate").rawValue;

this.resolveNode("SubmittedON").presence = "visible";

this.resolveNode("CurrentDate").presence = "hidden";

oTargetField = this.resolveNode("Page1");

    oTargetField.access = "readOnly";

//-

var cAdd = AdditionalNotes.rawValue;

var info = "Additional Notes for this request: ";

var EmpName = EmployeeName.rawValue;

var StrtDate = EffectiveDate.rawValue;

var Loc = Location.rawValue

var cBody = "The following is the completed New Employee Access Form for " + EmpName + " starting on "+StrtDate+" at "+Loc+ " .\n"+"\n" +info+cAdd;

if (cAdd == null){cBody = "Attached is the completed New Employee Access Form for "+EmpName+" starting on "+StrtDate+" at "+Loc+"."}

if (EmpName == null){

    EmpName = ""

    }else

    {

    EmpName = EmployeeName.rawValue

}

var myDoc = event.target;

try {

    myDoc.mailDoc({

        bUI: false,

        cTo: 'sbartholow@ppbi.com',

        cCc: 'khall@ppbi.com',

        cSubject: 'New Employee Form - '+EmpName+ " - " + StrtDate+ " - " + Loc,

        cSubmitAs: "PDF",

        cMsg: cBody

    });

} catch (e) {

}

Legend
August 8, 2019

Are you making the form in LiveCycle Designer or in Acrobat? They need different scripts. And I repeat: why this dangerous try/catch?