Adding attributes to the user task
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2011 09:17 PM
I need to create user tasks along with storing some attributes related to my business like based on purchase order the task are created so need to store the purchaseOrderId along with the task so that it could be used a search criteria.
Can anybody suggest me in achieving this?
Thanks
Can anybody suggest me in achieving this?
Thanks
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2011 03:27 AM
You can use task-local variables for this. Using the TaskQuery, you can ask for all tasks with a variable set the the given value:
taskService.createTaskQuery().taskVariableValueEquals("purchaseOrderId", "12345").list();
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2011 06:44 PM
how do i set the variables in the class MyAssignmentHandler
<userTask id="task1" name="My task" >
<extensionElements>
<activiti:taskListener event="create" class="org.activiti.MyAssignmentHandler" />
</extensionElements>
</userTask>
@Override
public void notify(DelegateTask delegateTask) {
delegateTask.setDescription("Purchase Order Task");
delegateTask.createVariableLocal("NumberAttribute1",delegateTask.getExecution().getVariable("puchaseOrderId"));
}
But this doesnt seem to work because my test case is not able to retrieve the task based on the variable set.
List<Task> taskList = taskService.createTaskQuery()//.list();
.taskVariableValueEquals("NumberAttribute1", purchaseOrderId).list();
This does not give me any results.
But if I do
List<Task> taskList = taskService.createTaskQuery().list();
It gives me the task created…
Any advice is welcome??
<userTask id="task1" name="My task" >
<extensionElements>
<activiti:taskListener event="create" class="org.activiti.MyAssignmentHandler" />
</extensionElements>
</userTask>
@Override
public void notify(DelegateTask delegateTask) {
delegateTask.setDescription("Purchase Order Task");
delegateTask.createVariableLocal("NumberAttribute1",delegateTask.getExecution().getVariable("puchaseOrderId"));
}
But this doesnt seem to work because my test case is not able to retrieve the task based on the variable set.
List<Task> taskList = taskService.createTaskQuery()//.list();
.taskVariableValueEquals("NumberAttribute1", purchaseOrderId).list();
This does not give me any results.
But if I do
List<Task> taskList = taskService.createTaskQuery().list();
It gives me the task created…
Any advice is welcome??
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2011 04:10 AM
Hi, you should use delegateTask.setVariableLocal(). Also, make sure the type of the Object set in 'setVariableLocal' is the same type as the one you use for querying (eg. Long).
