Journey Manager (JM)
The transaction engine for the platform. |
Form Builder Platform Developer | All versions
This feature is related to all versions.
A task is a form that has been prefilled with data and then assigned to a user. The typical use case for a task is: A user opens and completes a blank form. On submission, a task is created for another user, containing the original user's submitted data. The second user then reviews or modifies the data before submitting for processing.
Tasks can be assigned to Manager users, in which case they are accessed when that user logs into a portal, or they can be assigned anonymously, in which case a saved form is generated, and the URL is sent via email. Anonymously assigned tasks can be created in a groovy script by using the SubmissionTaskService
object.
The SubmissionTaskService API can be accessed at <Manager server>/manager/admin/javadoc/com/avoka/fc/core/service/SubmissionTaskService.html
The following groovy script can be used to assign anonymous tasks:
import com.avoka.fc.core.entity.*
import com.avoka.fc.core.dao.*
import com.avoka.fc.core.service.SubmissionTaskService
import com.avoka.fc.core.service.SubmissionTaskService.SavedFormParam
import com.avoka.fc.core.util.PortalUtils
import com.avoka.core.util.StringTemplate
import com.avoka.fc.core.service.EmailService
def formUrl = ""
// Setup the saved form parameter DTO
def param = new SavedFormParam()
// Setup the form parameter
def form = DaoFactory.getFormDao().getFormByFormCode( serviceParameters.FormCode ?: "" )
if(!form){ throw new Exception("Form Code is invalid, form not found.") }
param.form = form
// Setup the portal parameter
// uses the portal provided, if none provided, used the one configured as a service parameter.
def portalName = serviceParameters.PortalName ?: ""
def portal = DaoFactory.getPortalDao().getPortalByName( portalName )
if(!portal){ throw new Exception("Portal Name is invalid, portal not found") }
param.portal = portal
// Check the email serviceParameters
if(serviceParameters.SendEmailFlag){
if(!serviceParameters.ContactEmailAddress){ throw new Exception("Contact Email Address must be provided"); }
if(!serviceParameters.EmailSubject){ throw new Exception("Email Subject must be provided"); }
if(!serviceParameters.EmailMessage){ throw new Exception("Email Message must be provided"); }
}
// taskSubject
param.taskSubject = ""
// taskMessage
param.taskMessage = ""
// saveChallengeAnswer
param.saveChallengeAnswer = ""
// submissionXml
if(!serviceParameters.FormXml){ throw new Exception("Form Xml must be provided") }
param.submissionXml = serviceParameters.FormXml
// Create the task
def submissionTaskService = new SubmissionTaskService()
def submission = submissionTaskService.createAnonymousSavedForm(param)
// Task created, send notification email if required
//=======================================================================
if(serviceParameters.SendEmailFlag){
def emailService = new EmailService()
// Get the URL to resume the saved form
formUrl = PortalUtils.getFormSavedUrlWithReferenceNumber(portal, submission)
// Create data map for use in Velocity templates
def dataMap = [:]
dataMap.put("formUrl", formUrl)
def bodyStringTemplate = new StringTemplate(serviceParameters.EmailMessage)
def emailBody = bodyStringTemplate.merge(dataMap)
emailService.sendMessage(
serviceParameters.EmailSubject,
emailBody,
null,
serviceParameters.ContactEmailAddress,
"",
null)
}
return formUrl
To run the script, you need to configure the following service parameters:
ContactEmailAddress
: the email address that the URL of the created task is sent to.EmailSubject
: the email subject.FormCode
: The form code of the form used to generate the task. This form code must exist on the Manager server.FormXml
: The XML data used to prefill the generated task.PortalName
: A name of a form spacethat the form belongs to.SendEmailFlag
: true
to send the email to the assigned contact or false
otherwise.EmailMessage
: A Velocity Template of the email body HTML contains placeholders for dynamic content, such as $formUrl
, which will be populated with the link to a created task. For more information, see Apache Velocity Template Overview.An example of an email message velocity template is:
<html>
<head>
<style type="text/css">
/* custom CSS here */
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<!-- custom Content here -->
<div>
This is my message.<br>
Form Link: <a href="$formUrl">$formUrl</a>
</div>
</body>
</html>
Next, learn how to view Transact functions.