Expand my Community achievements bar.

Email PDF form on Web server

Avatar

Level 4

I have created a PDF form which resides on a Web server. Users follow a Webpage link and fill out the form on their desktop, where there is no email client installed. I noticed in the Script Editor that I can choose "Run at Server." Does this mean that when the user clicks Submit, this code will run on the server and email the form from there?

this.resolveNode("#event").submit.target = "mailto:" + strToAddress + "?subject= " + "LOA request for " + strSuffix + " DSM " + strMgrFirstName + " " + strMgrLastName + " Store# " + strStoreNum + " Region# " + strRegionNum;

Is that what "Run at Server" means? I looked in the LC Help and found no references to "Run at Server."

6 Replies

Avatar

Level 4

If "Run at Server" isn't the simple solution to my problem (there is no client email application), then could I copy the javascript code on the Submit button and paste it into a.js file on the server and then in the Object properties of the button point to that .js file?

form1.page3.emailSubform.emailToBtn::preSubmit:form - (JavaScript, server)

app.execMenuItem("SaveAs");

//either way below works
//event.target.submitForm({cURL:"mailto:"+ strToAddress + "?cc=" + strCCAddress + "&subject=" + strSubject + "&body=" + strMessage,cSubmitAs:"PDF",cCharset:"utf-8"});
if (txtCCAddress.rawValue == null) {
var strToAddress, strSubject, strMessage, strSuffix, strMgrFirstName, strMgrLastName, strStoreNum, strRegionNum

strToAddress = txtToAddress.rawValue;
strSuffix = form1.Page1.DropDownList1.rawValue;
strMgrFirstName = form1.page3.MgrFirstName.rawValue;
strMgrLastName = form1.page3.MgrLastName.rawValue;
strStoreNum = form1.Page1.storeNumber.rawValue;
strRegionNum = form1.page3.distRegion.rawValue;

//something like this would go in the URL in Object properties for the button
//formmail.php?emailTo=strToAddress&type=strSuffix&mgrFirst=strMgrFirstName&mgrLast=strMgrLastName&storeNum=strStoreNum&region=strRegionNum

this.resolveNode("#event").submit.target = "mailto:" + strToAddress + "?subject= " + "LOA request for " + strSuffix + " DSM " + strMgrFirstName + " " + strMgrLastName + " Store# " + strStoreNum + " Region# " + strRegionNum;
    }
    else
    {
    var strToAddress, strCCAddress, strSubject, strMessage, strSuffix, strMgrFirstName, strMgrLastName, strStoreNum, strRegionNum
   
strToAddress = txtToAddress.rawValue;
strCCAddress = txtCCAddress.rawValue;
strSuffix = form1.Page1.DropDownList1.rawValue;
strMgrFirstName = form1.page3.MgrFirstName.rawValue;
strMgrLastName = form1.page3.MgrLastName.rawValue;
strStoreNum = form1.Page1.storeNumber.rawValue;
strRegionNum = form1.page3.distRegion.rawValue;

    this.resolveNode("#event").submit.target = "mailto:"+ strToAddress + "?cc=" + strCCAddress + "&subject=" + "LOA request for "  + strSuffix + " DSM " + strMgrFirstName + " " + strMgrLastName + " Store# " + strStoreNum + " Region# " + strRegionNum;
    }

Avatar

Former Community Member

run at server means that the code wil execute on the server when it is rendered by Form Server. This will not do what you think it does.

Paul

Avatar

Level 4

Thank you. Is there another way to email the form on the server when the user clicks Submit. The email will go to one readonly text field with an address value already entered, and to a CC address, which the user can fill in.

Avatar

Former Community Member

You can submit the form to a simple program (any asp or php program will do) and that in turn can do the email. If you are looking to grab the address information from the form then I woudl send in an XDP format (include the PDF in that) then you wil have form and data. Your program can extract the nodes that giv ethe email address, then it can include the submitted PDF in the email as you want.

paul

Avatar

Level 4

Thank you for your suggestions. I'm finding that searching for a simple PHP form is not simple. Do you have one you could recommend or suggest that I try? Also, I read that Acrobat sends data via POST So PHP would grab the fields like this?

echo "Email To Address: {$_POST['strToAddress']}<br />";
   echo "Email CC Address: {$_POST['strCCAddress']}<br />";
   echo "Request Type: {$_POST['strSuffix']}<br /><br />";
   echo "Manager First Name:<br />{$_POST['strMgrFirstName']}<br /><br />";
   echo "Manager Last Name: {$_POST['strMgrLastName']}<br />";
   echo "Store Number: {$_POST['strStoreNum']}<br />";

That may be the general syntax, but in this case, it doesn't show any data. I'm just sending the form as PDF or as XML Data Package, and no data is displayed in the target PHP page.

Avatar

Former Community Member

No it will post an entire XML file. It will not post the name value pairs (although you could configure it to do that)....but all you have is the data .....you will still need the entire PDF doc ...that what I would submit. If you look at the options on th esubmit button you can submit an XDP file (XML Data Packet) that can contain the data and the finshed PDF (base64 encoded) in a single submission. Once you receive it in the server you can load it into an XML dom and retrieve the doc (decode it) and use it for your email attachment. Then you can get the individual nodes in the xml file to get the mail details.

I do not have a server program to share with you ...maybe someone else on this forum does.

Paul