Copy link to clipboard
Copied
I have created a form and need to be able to let the user pick the email address from a drop-down menu, for the person who needs to receive the completed form. I have named the drop-down field "EmailTo" and used this script I found on tutorials.
// Set the target email address based on the selection in the field
var cToAddr = this.getField("EmailTo").value;
// Set the subject and body text for the email message
var cSubLine = "Legal Document Submission"
var cBody = "Thank you for submitting your form.\n" + "Save the filled form attachment for your own records.\n" + "Attach the orginal legal document to this email"
// Send the entire PDF as a file attachment on an email
this.mailDoc({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});
I am getting this security warning message when I pick an email address and want to know if there is a way to prevent it from popping up.
Thank you for any assistance.
It seems the value of this field is not an email address but some text ("set the target email address..."), which the script is then trying to use as the target email. This will not work, of course. You have to either replace that text with an empty string, or not proceed with sending the file if the entered value is not a valid email address.
It is picking up the text "set the target email address..."
This is NOT coming from the comment (though I can see why you might think so).
It is probably coming from a form field. Check all your form fields for this text. My guess is that you have this in the list of emails, as well as some email addresses.
Copy link to clipboard
Copied
What have you selected in the dropdown? Where does you use the script?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
At the dropdown have you only the 3 choices or more?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Is the text "set the target email address..." one of the choices or export values.
Copy link to clipboard
Copied
This is the dialog box, there is a field for export value, I don't know what to put there though
Copy link to clipboard
Copied
It seems the value of this field is not an email address but some text ("set the target email address..."), which the script is then trying to use as the target email. This will not work, of course. You have to either replace that text with an empty string, or not proceed with sending the file if the entered value is not a valid email address.
Copy link to clipboard
Copied
Thank you for the response, I do not know Javascript but can see now that the security warning is saying it is trying to connect to what I thought was just a comment in the script, it's the first line. Any suggestions to fix this code would be greatly appreciated.
// Set the target email address based on the selection in the field
var cToAddr = this.getField("EmailTo").value;
// Set the subject and body text for the email message
var cSubLine = "Legal Document Submission"
var cBody = "Thank you for submitting your form.\n" + "Save the filled form attachment for your own records.\n" + "Attach the orginal legal document to this email"
// Send the entire PDF as a file attachment on an email
this.mailDoc({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});
Copy link to clipboard
Copied
It is picking up the text "set the target email address..."
This is NOT coming from the comment (though I can see why you might think so).
It is probably coming from a form field. Check all your form fields for this text. My guess is that you have this in the list of emails, as well as some email addresses.
Copy link to clipboard
Copied
Also, WHERE do you use the script? This is critical, there are many different places a script can be. Nothing works in the wrong place.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Can you share the form?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Working fine for me...
Copy link to clipboard
Copied
It works without any issue.