Asite enables generation of custom XML output from existing form data within the project, with the help of workflow system tasks. Below are the steps for configuring workflow to generate XML output:
Step 1: Create a system task with groovy script configured to generate custom XML output from form data.
Below is the snippet of a sample groovy script:
|
Groovy script configuration includes 3 main stages:
1. Defining information that need to be read
|
Script highlighted above is an example where administrator will have to map the information that need to be read from the form.
Below is the general syntax for retrieving any information from the form, syntax contains 2 main parameters as explained below:
|
'Variable Name' could be any name administrator can use to identify the information.
Include function to read the relevant form information.
System allows user to read standard/custom form fields defined within the form:
To read standard fields i.e. any field that is captured by default by Asite system. (e.g. Title, Form Originator, Form Created Date, etc...), use the functions to extract standard field as mentioned below:
formVo.getProjectName() – To read project name
formVo.getFormCodeNum() – To read form code
Click here to learn more about other standard functions accessible.
Finally the syntax to read a system field within the groovy script will look like:
dataMap.put("PROJECT_NAME", formVo.getProjectName()); //
This will read project name
dataMap.put("FORM_ID", formVo.getFormCodeNum()); // This will read form ID e.g. EMP001
To read custom fields i.e. any field placed with the form design other than standard fields( e.g. Employee Name, Employee Email ID, Employee Address, etc...), use the formService function as mentioned below to extract custom field information:
formService.getFormFieldValuesFromXML(inputXml, "<<Field Name>>"));
Administrator can replace the ‘Field Name’ with the actual field name from the form design.
Finally the syntax to read a custom field within the groovy script will look like:
dataMap.put("First_Name", formService.getFormFieldValuesFromXML(inputXml, "First_Name")); // This will read the data from field named ‘First_Name’
dataMap.put("Last_Name", formService.getFormFieldValuesFromXML(inputXml, "Last_Name")); // This will read the data from field named ‘Last_Name’
2. Defining the output format of the XML
|
Script highlighted above is the example how an administrator can define the output format tags in which they expect the XML output. The general syntax to define the output format is:
<’TagName’> ##Variable Name </’TagName>
Administrator will have to mention the mapping ‘Variable Name’ from the definitions mentioned in section above. Administrator can add as many XML tags that are required within the final XML output. Finally the syntax for output format of XML within the groovy script will look like:
<EMPLOYEE> <PROJECT>##PROJECT_NAME</PROJECT> <PROJECTID>##FORM_ID</PROJECTID> <FNAME>##First_Name</FNAME> <LNAME>##Last_Name</LNAME> </EMPLOYEE>
3. Defining email body and recipient of email
|
Administrator can configure the groovy script to define the body and recipients of the email.
Administrator will have to define the email content in the variable for ‘emailBody’, and then use that variable in the function. Below is an example of defining content within the email body:
String emailBody = "Hi, <BR/><BR/> A new employee have joined Asite. <BR/><BR/> Thanks";
Administrator can define the recipient of the email, multiple recipient can be added as recipient. Below is an example of defining email recipient:
List<String> toRecipient = new ArrayList<>();
toRecipient.add("email1@example.com"); // The mentioned recipient will be main recipient of email
toRecipient.add("email2@example.com");// The mentioned recipient will be main recipient of email
List<String> cCRecipient = new ArrayList<>();
cCRecipient.add("email3@example.com"); // The mentioned recipient will be copy recipient of email
Administrator will then have to use the variable in the relevant functions in the groovy script above, below are the final resultant groovy script function replaced with the variables:
mailDataMap.put(IGroovyConstant.RECEIPIENT_ADMINISTRATORS, toRecipient);
mailDataMap.put(IGroovyConstant.CC_RECEIPIENT_ADMINISTRATORS, cCRecipient);
mailDataMap.put(IGroovyConstant.SUBJECT, "Employee Information"); //This is where administrator will be able to define the email subject
mailDataMap.put(IGroovyConstant.MAIL_BODY, emailBody);
Step 2: Create a workflow trigger on the required form to use the system task as configured in previous step.
Step 3: Perform the task as per trigger configuration to execute the workflow system task.
Next Article: Push issues on a federated model to 3D Repo