These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Retrieving form values

John.Rhoda
Registered: Aug 3 2009
Posts: 16

I'm trying to retrieve values from a form to be part of an e-mail. The email part works just fine but I cannot get the values of the form to show up. I have a text field in the form named Procedure which contains the text I want to display in the e-mail.

var cMyMsg = "Below are the current budget figures:\n\n";
cMyMsg += "Date Compiled: " + resolveNodes("form1.#TopPage.Procedure").rawValue + "\n";
cMyMsg += "Current Estimate: " + resolveNodes("Procedure").value + "\n";

app.mailMsg({bUI: true,

cTo: "email [at] email [dot] com,

cSubject: "Signed Hazard Analysis",

cMsg: cMyMsg,

});

Thanks,
John

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The function app.maiMsg only sends an e-mail message without any attachments.
You should use the doc.mailDoc()-function in the click event of a regular button.

var myDoc = event.target;var address = "<span class="spamspan"><span class="u">email</span> [at] <span class="d">email [dot] com</span></span>";var sub = "Signed Hazard Analysis";var msgBody = "Below are the current budget figures:\n\n\Date Compiled: " + resolveNodes("form1.#TopPage.Procedure").rawValue + "n\Current Estimate: " + resolveNodes("Procedure").value + "\n\n"; myDoc.mailDoc({bUI: false,cTo: address,cSubject: sub,cMsg: msgBody,cSubmitAs: "PDF"});

PS: More information about the mail functions can be found here:
http://www.acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

John.Rhoda
Registered: Aug 3 2009
Posts: 16
I am not looking for an attachment just an email with text but I want to pull the text from a filled in field named "Procedure". With your code I am still getting "undefined" instead of the text
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
What's shown in the JS-Debugger (ctrl + J) when you click you button?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

John.Rhoda
Registered: Aug 3 2009
Posts: 16
My finished code and the error message:

var myDoc = event.target;
var address = "email [at] email [dot] com";
var sub = "Signed Hazard Analysis";
var msgBody = "The Hazard Analysis for SOP: " + resolveNodes("form1.#TopPage.Procedure").rawValue + "n\" + resolveNodes("Title").value + "\n has been signed\n";

myDoc.mailDoc({
bUI: false,
cTo: address,
cSubject: sub,
cMsg: msgBody,
cSubmitAs: "PDF"
});

missing ; before statement
4:XFA:form1[0]:TopPage[0]:Button4[0]:click
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
I tested your script, there where little changes neccessary.

var cMyMsg = "Below are the current budget figures:\n\n";cMyMsg += "Date Compiled: " + resolveNodes("form1.#TopPage.Procedure").rawValue + "\n";cMyMsg += "Current Estimate: " + xfa.resolveNode("???.???.Procedure").rawValue + "\n"; app.mailMsg({bUI: true,cTo: "<span class="spamspan"><span class="u">email</span> [at] <span class="d">email [dot] com</span></span>",cSubject: "Signed Hazard Analysis",cMsg: cMyMsg,});

1. You missed an " in your mail address line
2. The location of your 2nd "Procedure" you use for "Estimate" is unclear.
You should use a fully qualified path for xfa.resolveNode("form1.???.Procedure").rawValue

For me it the worked fine!

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
John.Rhoda wrote:
My finished code and the error message:var myDoc = event.target;
var address = "email [at] email [dot] com";
var sub = "Signed Hazard Analysis";
var msgBody = "The Hazard Analysis for SOP: " + resolveNodes("form1.#TopPage.Procedure").rawValue + "n\" + resolveNodes("Title").value + "\n has been signed\n";

myDoc.mailDoc({
bUI: false,
cTo: address,
cSubject: sub,
cMsg: msgBody,
cSubmitAs: "PDF"
});

missing ; before statement
4:XFA:form1[0]:TopPage[0]:Button4[0]:click
Well, this may be caused from catching the values of the fields directly.
Solution is to define the values as variables first.

var A = xfa.resolveNode("form1.#TopPage.Procedure").rawValue;var B = xfa.resolveNode("form1.Page1.Procedure").rawValue;var myDoc = event.target;var address = "<span class="spamspan"><span class="u">email</span> [at] <span class="d">email [dot] com</span></span>";var sub = "Signed Hazard Analysis";var msgBody = "The Hazard Analysis for SOP: " + A + "n\" + B + "\n has been signed\n"; myDoc.mailDoc({bUI: false,cTo: address,cSubject: sub,cMsg: msgBody,cSubmitAs: "PDF"});

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

John.Rhoda
Registered: Aug 3 2009
Posts: 16
now i get a new error


illegal character
6:XFA:form1[0]:TopPage[0]:Button4[0]:click
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
OK, which script did you use?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

John.Rhoda
Registered: Aug 3 2009
Posts: 16
var A = xfa.resolveNode("form1.#TopPage.Procedure").rawValue;
var B = xfa.resolveNode("form1.#TopPage.Title").rawValue;
var myDoc = event.target;
var address = "email [at] email [dot] com";
var sub = "Signed Hazard Analysis";
var msgBody = "The Hazard Analysis for SOP: " + A + "n\" + B + "\n has been signed\n";

myDoc.mailDoc({
bUI: false,
cTo: address,
cSubject: sub,
cMsg: msgBody,
cSubmitAs: "PDF"
});
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Ahh, wait, the error is this script fragment "n\".
It should look "\n".

var A = xfa.resolveNode("form1.#TopPage.Procedure").rawValue;var B = xfa.resolveNode("form1.#TopPage.Title").rawValue;var myDoc = event.target;var address = "<span class="spamspan"><span class="u">email</span> [at] <span class="d">email [dot] com</span></span>";var sub = "Signed Hazard Analysis";var msgBody = "The Hazard Analysis for SOP: " + A + "\n" + B + "\nhas been signed\n"; myDoc.mailDoc({bUI: false,cTo: address,cSubject: sub,cMsg: msgBody,cSubmitAs: "PDF"});

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

John.Rhoda
Registered: Aug 3 2009
Posts: 16
now I get this error:

xfa.resolveNode("form1.#TopPage.Procedure") has no properties
1:XFA:form1[0]:TopPage[0]:Button4[0]:click
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The devil is in the detail.
Have a look to your script again, there might be an error in the SOM expression for "Procedure".

var A = xfa.resolveNode("form1.#TopPage.Procedure").rawValue;
To be sure to get the corret SOM expression just hold down ctrl + shift at the same time and then click on the form object "Procedure".
The full path will be added to the script editor.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

John.Rhoda
Registered: Aug 3 2009
Posts: 16
I've got the code working now I was wondering what I would have to change in order to not have it attach the pdf to the email