Email Submit button to one external address

deanr91271723

24-04-2017

When I add an email Submit Button it only comes to me as the creator of the form.

I would like it to go to another external Sales email address only.

I have looked on line and have found some other scripts but they don't do exactly what I am looking for.

Script I have used goes to an external but also to me along with providing additional inputs.

I have tried to remove the additional inputs but then the script doesn't work.

Help on this issue would be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Karl_Heinz_Krem

26-04-2017

Sorry for the delay, but participating here in the forums comes after family, work, eating and sleeping, so sometimes it takes a bit longer until I can reply

I assume this is happening in the free Reader. The reason for this is that even though recent versions of the free Reader can fill and save AcroForms (the type of form you create in Adobe Acrobat), XFA forms (the ones created in LiveCycle Designer) are not supported by this "free" feature. You will have to reader-enable your form in Adobe Acrobat. In Acrobat DC for example, you would select File>Save As Other>Reader Extended PDF>Enable More Tools. Once you've done that, you should be able to fill and save in both Acrobat and the free Reader.

Answers (49)

Answers (49)

Karl_Heinz_Krem

01-05-2017

Dean,

As I mentioned before, the error message points to the resolveNode() call returning null because it cannot find the field name you've specified. In XFA forms, it's important that you know where your fields are, relative to where you want to use them.

I would suggest that you let Designer figure out how it can "get to" the field in question. You can do this by using the following approach.

The line that is not working is as follows:

var cCCAddr = xfa.resolveNode("ClientEmail").rawValue;

Remove the "xfa.resolveNode("...") from the code and then place your cursor right before the ".rawValue;". Now hold down the Ctrl key and click on the "ClientEmail" field in the design view. Based on the form you're provided, Designer will change this line to

var cCCAddr = WindowInformation.ClientEmail.rawValue;

Do this will all the field references that are causing you problems. There are different ways you can get a reference to a field in an XFA form - xfa.resolveNode is one way, but for simple names, you can just use the field name (unless it contains special characters, or starts with a digit) - and this is what Designer does in this case.

Karl_Heinz_Krem

27-04-2017

This error message indicates that the script has a problem getting the value of the field ClientEmail - this is not related to your overall email issue you had when you started this question.

deanr91271723

27-04-2017

I believe the error in regards to the email is the only issue at hand but I do appreciate your time & help.

You have been very helpful

TypeError: xfa.resolveNode("ClientEmail") is null

7:XFA:form1[0]:Page1[0]:Data[0]:Button1[0]:click

Dan R

Karl_Heinz_Krem

27-04-2017

This again is a problem that has nothing to do with the original question.

I wish I could spend more time on your problem, but I am in the midst of

racing agains a deadline. Your chances of getting somebody else to chime in

are much higher if you post a new question.

deanr91271723

27-04-2017

This is what I see after pushing the Submit button several time.

TypeError: xfa.resolveNode("ClientEmail") is null

7:XFA:form1[0]:Data[0]:Button1[0]:click

TypeError: xfa.resolveNode("ClientEmail") is null

7:XFA:form1[0]:Data[0]:Button1[0]:click

TypeError: xfa.resolveNode("ClientEmail") is null

7:XFA:form1[0]:Data[0]:Button1[0]:click

This is what the Script looks like (email name changed):

// This is the form return e-mail. Its hardcoded

// so that the form is always returned to the same address

// Change address on your form

var cToAddr  = "sales123@123.com";

// First, get the client CC e-mail address

var cCCAddr = xfa.resolveNode("ClientEmail").rawValue;

  1. console.println("Client: " + cCCAddr);

// Now get the beneficiary e-mail only if it is filled out

var cBenAddr = xfa.resolveNode("BennyEmail").rawValue;

  1. console.println("Benny: " + cBenAddr);

if(cBenAddr != "")

    cCCAddr += ";" + cBenAddr;

// Set the subject and body text for the e-mail message

var pn = xfa.resolveNode("polisnummer").rawValue;

var cSubLine = "Form X-1 returned from client " + pn;

var cBody = "Thank you for submitting your form.\nSave the mail attachment for your own records";

// Send the form data as an PDF attachment on an e-mail

  1. event.target.mailDoc({

      bUI: false,

      cTo: cToAddr,

      cCc: cCCAddr,

      cSubject: cSubLine,

      cMsg: cBody,

  });

Karl_Heinz_Krem

27-04-2017

Again, what you describe sounds like you are running this in Reader and not in Acrobat. Most of these error messages are about a validation event. I would recommend that you post a different question about these errors, they don't seem to have anything to do with your original email submission problem. This way, you may get some new eyes on your problem.

Karl_Heinz_Krem

27-04-2017

This sounds like you are running the free Reader, and not Adobe Acrobat Pro. When you go to the "Help" menu and look at the "About" option, what does it say?

deanr91271723

27-04-2017

I had to look into preferences and turn on Javascript  Debugger and now I get a pop up window when I select submit button.

Seem to be more with format of page then the submit button.

Below is what I see in the Debug page:

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:E1000-Costing-Subform[0]:E1000-BaseCost[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:ES1000-Costing-Subform[0]:ES1000-BaseCost[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:ES1500-Costing-Subform[0]:ES1500-BaseCost[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:ES1750-Costing-Subform[0]:ES1750-BaseCost[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:CT2000-Costing-Subform[0]:CT2000-BaseCost[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD600-Costing-Subform[0]:WD600-BasePricing[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD600-Costing-Subform[0]:WD600-PaintFinishAdder[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD600-Costing-Subform[0]:WD600-PowderFinishAdder[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD800-Costing-Subform[0]:WD800-BaseCost[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD800-Costing-Subform[0]:WD800-PaintFinishAdder[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD800-Costing-Subform[0]:WD800-PowderFinishAdder[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD1000-Costing-Subform[0]:WD1000-BaseCost[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD1000-Costing-Subform[0]:WD1000-PaintFinishAdder[0]:validate

ReferenceError: invalid assignment left-hand side

3:XFA:form1[0]:Page2-CostingSheet[0]:WD1000-Costing-Subform[0]:WD1000-PowderFinishAdder[0]:validate

TypeError: xfa.resolveNode(...) is null

9:XFA:form1[0]:Data[0]:Button1[0]:click

TypeError: xfa.resolveNode(...) is null

9:XFA:form1[0]:Data[0]:Button1[0]:click

deanr91271723

27-04-2017

I am using Adobe Acrobat XI Pro to read but see no option to check Java.

If I go to additional tools I have the option to purchase but nothing commonly available.

In LiveCycle I can check script syntax but get no highlighted lines or expressed errors.

Karl_Heinz_Krem

27-04-2017

Does this happen on both Acrobat and the free Reader? if it also happens in Acrobat, then open up the JavaScript console (Ctrl-J) and look for error messages. If it only happens in Reader, open up Reader's Preferences, go to the JavaScript category and enable  "Show console on errors and messages".

Exception handing in JavaScript is nothing specific to Acrobat, it's just standard JavaScript. Here is some information about how to do that: https://www.w3schools.com/js/js_errors.asp

deanr91271723

27-04-2017

I am not familiar with "Try/Catch exception handler", how is it applied?

Using the same script after modifications to email address and making sure the ClientEmail field matches I am still not getting an email window to send as if the script is not running again?

Have opened and saved through Adobe Saved Enabled, is there something I am missing or another change that is required?

Note: I am not using the BennyEmail field but haven't changed the Script to remove it which is what I did on previous form.

Karl_Heinz_Krem

27-04-2017

No need to distribute, just attach the reader-enabled file to an email or upload it to a web page. When you "Distribute", Acrobat will actually try to reader-enable the document as well.

The script is form specific, because it is trying to get information from certain fields. If these fields are not there, you will have to either adjust the script, or make it resistant against missing information. You can do that using a try/catch exception handler.

deanr91271723

27-04-2017

Karl,

I have tried to apply this same Script to another form but it appears nothing happens when I select Submit.

I have changed to a standard Button, placed the script on the Click selection, save.

Open in Adobe and followed the Save to Enable more tools but when I select Submit I don’t get the email window or see any action.

I didn’t see where this Script was form specific. Is it?

Dean R

deanr91271723

27-04-2017

Karl,

Thank you for the feedback on this.

Making these changes does run the script and open an email page to send to the correct address.

Once saved to Enable more tools is it required to Distribute the file again?

Seems like when I Distribute it reverts back and won’t open email page.

Dean R

deanr91271723

26-04-2017

Karl,

When I add a Button, drop the Script into the “Click” feature and try it I get a warning that I can’t save the filled in form.

The Form is saved as a Dynamic XML and I never had this until I changed the Button?

Do you know the cause of this?

Dean R

deanr91271723

25-04-2017

Karl,

When I add a Button, drop the Script into the “Click” feature and try it I get a warning that I can’t save the field in form.

The Form is saved as a Dynamic XML and I never had this until I changed the Button?

Dean R

Karl_Heinz_Krem

25-04-2017

You are using an email submission button - which sounds like the right thing to do, but in this case that's wrong: The stock email submission button is a one-trick pony, and it does exactly what it's designed to do: It submits the form to the email address you used when you first set up the form. As you may have noticed, you cannot add a "click" handler to this button (and I assume that's the reason why you added the script as a mouse-up event handler), because it's already hard coded to do that one thing. You will need to add a normal "Button" and then add the script as a click handler.

Karl_Heinz_Krem

25-04-2017

I tried to send you a direct message with my email address, but the forum software is not cooperating right now. When you click on my name in blue just above this comment, you can find a link to my web site, which has my email address in the lower right corner. I cannot promise that I will get to your document right away - my paying customers always come first.

deanr91271723

25-04-2017

Karl,

I am not seeing anything run when submit button is clicked.

I am distributing the form and then opening the PDF in Adobe Acrobat Reader, filling it out and submitting.

Just tried to open original undistributed form, filling it out and submitting but saw nothing run and didn’t receive a returned form?

Is there a way to send you a copy of the form for review?

Dean R

Karl_Heinz_Krem

25-04-2017

This looks like this document is part of a "distribute form" workflow. This means that you are very likely not even running the script that is associated with the button. BTW: You should see some output on the JavaScript console. There are a few "console.println()" commands in my code to print the field information retrieved from the form. If you don't see that, the script is not running, and therefore you are not getting any of the behavior programmed in it.

Are you using the "distribute form" function in Acrobat? If so, have you tried to just load the original form, without having Acrobat modify it?

deanr91271723

25-04-2017

Karl,

When I check the Script I get no errors.

I had sent a screen shot but.. apparently didn’t come through, I see nothing in the CC field or a CC field when I receive the filled out form.

Will upload a snap shot of what I see

Dean R

Karl_Heinz_Krem

25-04-2017

So again my questions: Do you get any errors on the JavaScript console? What do you see in the "CC:" field in the email that arrives at the "To:" address?