11-25-2016 12:36 AM
12-22-2016 03:38 AM
Hi Manav Aahuja,
Have a look at Activiti documentation for implementing Forms here: Activiti User Guide
In a nutshell, in order to implement user task variables correctly, you need to do the following:
- Imagine a process such as book order which consists of several service tasks and 2 user tasks as follows
- Design your process variables such as: isbn, validationResult
- When the process instance reaches the first user task, say, review order. You would need to 'map' the process variables to form properties like below (note that I have the form property ids to be exact to process variables name to utilize the Activiti form properties auto mapping. You don't have to. Read documentation here Activiti User Guide to know how to map form properties to process variables with different names.
<userTask id="task"> <extensionElements> <activiti:formProperty id="isbn" /> <activiti:formProperty id="validationResult"/> </extensionElements> </userTask>
- Then you do the same for the 2nd user task 'Final Approval'. This will map process variables to form properties displayed on form 'Final Approval'.
- I have 2 service tasks for demo purposes. First one to initialize the process variables and the second is to update validationResult variable to stimulate a successful validation after Review task.
My unit test ran successfully. I could see correct values of form properties on each user task and both user tasks were submitted successfully which end the process instance.
INFO: Task form: reviewForm
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = caseId value = 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = caseName value = Book order case 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = isbn value = 343
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = validationResult value = false
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Submit Review
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Update validation result to true for execution id 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Process execution: id: 5 and current activity id= usertask3
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Execution variables: {Case ID=null, caseId=5, ISBN=null, isbn=343, Case Name=null, validationResult=true, bookOrder=org.activiti.designer.test.BookOrder@70bd9535, caseName=Book order case 5}
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Task 2 form: finalApprovalForm
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = caseId value = 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = caseName value = Book order case 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = isbn value = 343
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = validationResult value = true
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Submit Final Approval
Dec 22, 2016 3:31:22 PM java.util.logging.LogManager$RootLogger log
INFO: Running processes: 0
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.993 sec
Dec 22, 2016 3:31:22 PM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.context.support.GenericApplicationContext@5d277b59: startup date [Thu Dec 22 15:31:17 ICT 2016]; root of context hierarchy
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ activiti-examples ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ activiti-examples ---
[INFO] Installing /home/osboxes/workspace/activiti-hello/target/activiti-examples-1.0-SNAPSHOT.jar to /home/osboxes/.m2/repository/org/activiti/examples/activiti-examples/1.0-SNAPSHOT/activiti-examples-1.0-SNAPSHOT.jar
[INFO] Installing /home/osboxes/workspace/activiti-hello/pom.xml to /home/osboxes/.m2/repository/org/activiti/examples/activiti-examples/1.0-SNAPSHOT/activiti-examples-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.149s
[INFO] Finished at: Thu Dec 22 15:31:22 ICT 2016
[INFO] Final Memory: 11M/166M
[INFO] ------------------------------------------------------------------------
So I would double check several things in your implementation:
- First, verify your process variables <-> form properties mapping and see if its done correctly
- Second, verify your submission code to see if there's any error. If you still see the error, what is it?
I have attached my unit test code for reference,
Hope this helps,
Thanks,
Thong Huynh
12-13-2016 03:54 AM
Define variables and use them at process instance level.
12-22-2016 03:38 AM
Hi Manav Aahuja,
Have a look at Activiti documentation for implementing Forms here: Activiti User Guide
In a nutshell, in order to implement user task variables correctly, you need to do the following:
- Imagine a process such as book order which consists of several service tasks and 2 user tasks as follows
- Design your process variables such as: isbn, validationResult
- When the process instance reaches the first user task, say, review order. You would need to 'map' the process variables to form properties like below (note that I have the form property ids to be exact to process variables name to utilize the Activiti form properties auto mapping. You don't have to. Read documentation here Activiti User Guide to know how to map form properties to process variables with different names.
<userTask id="task"> <extensionElements> <activiti:formProperty id="isbn" /> <activiti:formProperty id="validationResult"/> </extensionElements> </userTask>
- Then you do the same for the 2nd user task 'Final Approval'. This will map process variables to form properties displayed on form 'Final Approval'.
- I have 2 service tasks for demo purposes. First one to initialize the process variables and the second is to update validationResult variable to stimulate a successful validation after Review task.
My unit test ran successfully. I could see correct values of form properties on each user task and both user tasks were submitted successfully which end the process instance.
INFO: Task form: reviewForm
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = caseId value = 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = caseName value = Book order case 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = isbn value = 343
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: REVIEW FORM -- property id = validationResult value = false
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Submit Review
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Update validation result to true for execution id 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Process execution: id: 5 and current activity id= usertask3
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Execution variables: {Case ID=null, caseId=5, ISBN=null, isbn=343, Case Name=null, validationResult=true, bookOrder=org.activiti.designer.test.BookOrder@70bd9535, caseName=Book order case 5}
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Task 2 form: finalApprovalForm
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = caseId value = 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = caseName value = Book order case 5
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = isbn value = 343
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: APPROVAL FORM -- property id = validationResult value = true
Dec 22, 2016 3:31:21 PM java.util.logging.LogManager$RootLogger log
INFO: Submit Final Approval
Dec 22, 2016 3:31:22 PM java.util.logging.LogManager$RootLogger log
INFO: Running processes: 0
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.993 sec
Dec 22, 2016 3:31:22 PM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.context.support.GenericApplicationContext@5d277b59: startup date [Thu Dec 22 15:31:17 ICT 2016]; root of context hierarchy
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ activiti-examples ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ activiti-examples ---
[INFO] Installing /home/osboxes/workspace/activiti-hello/target/activiti-examples-1.0-SNAPSHOT.jar to /home/osboxes/.m2/repository/org/activiti/examples/activiti-examples/1.0-SNAPSHOT/activiti-examples-1.0-SNAPSHOT.jar
[INFO] Installing /home/osboxes/workspace/activiti-hello/pom.xml to /home/osboxes/.m2/repository/org/activiti/examples/activiti-examples/1.0-SNAPSHOT/activiti-examples-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.149s
[INFO] Finished at: Thu Dec 22 15:31:22 ICT 2016
[INFO] Final Memory: 11M/166M
[INFO] ------------------------------------------------------------------------
So I would double check several things in your implementation:
- First, verify your process variables <-> form properties mapping and see if its done correctly
- Second, verify your submission code to see if there's any error. If you still see the error, what is it?
I have attached my unit test code for reference,
Hope this helps,
Thanks,
Thong Huynh
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.