This is another question I get quite frequently. I’m posting here an extended description so that I can point to this blog if I get this asked again 😉
For the implementation of an offline scenario based on SAP Interactive Forms you have a couple of options how to submit data back to the SAP backend (e.g. HTTP post, email or Web Services).
In this blog I’m talking about submitting data via an email submit button. The scenario is basically as follows. An external person has to be included into a business process (e.g. to correct existing data or add additional data or to confirm something). This person has no access to the SAP system through SAPGUI or a portal. To include this person into the process an Interactive Forms is created in the SAP backend. The form is pre-populated with all relevant information and automatically sent out (e.g. via Business Communication Service). The person receives the Interactive Form as an attachment of an email, works with it and when finished presses the email submit button. Then the desktop email client is used to send back data (either as PDF or XML data depending on the selected option during form design).
I create the email button on the form based on the standard button. I drag and drop the button onto the form and then take a look at the properties. In the “field” tab of the object palette you can find the “control type”. I just set it to “submit”. Doing this I get an additional tab called “submit”. This tab contains a field where you can enter the “Submit to URL”. If you want to submit data via email you have to use an “mailto:” URL.
The email address shouldn’t be contained in the form template. It should be data driven so that it can be changed without touching the template. So let’s assume that the email address is contained in the form data (e.g. in a node that is not bound to any field on the form).
First of all we have to find out where the URL is stored in the template. The XFA Specification helps us here (see also my Useful documentation for developing Interactive Forms). It tells us that a submit button has a node “event”. This node has another subnode called “submit” and this node has a property called “target”. To dynamically set the submit-to URL we have to script against this property.
xfa.resolveNode(“form1.page1.Button1.#event.#submit”).target = “mailto:”+$record.emailaddress.value;
this.resolveNode(“#event.#submit”).target = “mailto:”+$record.emailaddress.value;
The second resolveNode call is relative to the node where the call is made (in this example the initialize event of “Button1”). The SOM expression $record.emailaddress is used to access the data node (these expressions are case sensitive!).
You could do even more fancy stuff like setting the subject and a body text for the email.
xfa.resolveNode(“form1.page1.Button1.#event.#submit”).target = “mailto:”+$record.emailaddress +”?subject=”+$record.emailsubject+”&body=”+$record.emailbody;
You can take a look at the mailto RFC for other parameters.
Note: The email client has to support MAPI. Otherwise this will not work properly.