We need to create a quick link that opens a form when clicked. After the user enters the required details and submits the form, a task result should be generated without creating a work item, since the information is sensitive.
Can anyone please provide suggestion/approach without generating the Workitem, taskresult should be generated.
@AkashRaavi131 Could you please provide more details on what do you want to do with task result? and work items will be generated if you don’t have transient set to true and for approvals. I think you may need to bit more details about your use case?
Also, from the form workflow, you can launch a task with all necessary details and it should generate the task result for you.
We are following the same approach, but unable to get the data in taskresult.
Yes, we are setting workflow variable transient set to true for not generating the workitem.
The task result should contain the user data which is submitted in the form and task status success or failure .
can you please provide any code snippet for getting user details in the task.
@AkashRaavi131 How are you sending the data to workflow?
you need to use TaskManager to launch the task and send the attributes. sample script:
Map taskMap = formModel ;//or a map of all form details
TaskManager tm = new TaskManager(context);
Attribute attr = new Attributes(taskMap);
tm.run(<taskname>, attr);
This should launch the task and you’ll have access to the form details as well. If you want it in the task result object as well, then you can actually launch a rule runner task where in the rule, you’ll have taskResult object available on which you can again set the attributes using setAttributes method.
Try this out and let us know for any further queries.
Thank you,
Yes , using the TaskManager to launch the task.
Can you please provide code snippet / suggest how to retrieve the data to the task rule from the workflow.
@AkashRaavi131 You already have taskResult object available in the rule associated with Rule runner task. You can use it to get the task and then set the attributes. Sample Code:
if(taskResult!=null){
TaskDefinition taskDef = taskResult.getDefinition()
Attribute taskAttr = taskDef.getAttributes();
//either set the complete task attr or get the attribute which you want and stor
taskResult.setAttributes(taskAttr);
}
It’s unclear what you want here, so here is an info-dump:
The user’s form is a WorkItem. That’s just what a user-facing form is.
You can set the Workflow itself to transient by setting the value of that Workflow variable to true. This will prevent a TaskResult from being created by default. This also means that the WorkItem will not be saved if the user clicks a “cancel” type button, rather than “back” or “next”.
If your Workflow ever needs to persist itself, e.g., because the WorkItem is assigned to someone other than the person who clicked the QuickLink or you have wait on a step, it will create a TaskResult automatically.
If you need to create a TaskResult only in some cases, but the rest of the time you want it to be transient, you can do this in a Workflow step:
If your data is truly that sensitive, you can add an <AfterScript> on your Approval step, which will be able to intercept the form results before they get persisted back to the WorkflowCase.
And finally, the only variables written to the TaskResult at all are those marked with output=”true” in the Variables section of your Workflow.