08-02-2018 03:49 AM
Hi all,
I'm setting custom properties (defined on startTask model) when starting workflows.
I want to update some of these properties after the workflow starts.
When trying to update startTask properties:
this.services.getWorkflowService().updateTask(startTask.getId(), customProps, null, null);
It fails with exception: "Unable to update task because it does not exists"
Caused by: org.alfresco.service.cmr.workflow.WorkflowException: 07020004 Impossible de mettre à jour la tâche de workflow activiti$start424424 car cette tâche n'existe pas. at org.alfresco.repo.workflow.activiti.ActivitiWorkflowEngine.updateTask(ActivitiWorkflowEngine.java:2365) at org.alfresco.repo.workflow.WorkflowServiceImpl.updateTask(WorkflowServiceImpl.java:981)
Any idea ?
Thanks,
Vincent
08-03-2018 03:12 AM
You can never update a start task. Start tasks are "pseudo"-tasks - they technically do not exist. Using the Alfresco WorkflowService it is impossible to update workflow properties after a workflow has been started. Any update needs to happen as part of task / execution listeners within the workflow itself, i.e. you can set variables to update in a currently active task, and when that task is complete, a task listener copies the relevant properties into the process instance / execution, where all the workflow properties are stored.
08-03-2018 04:56 AM
Thanks Axel for your response
I just want to query all workflow instances and return, for each of them a task status summary. I developped a REST API webscript to do that, but when querying tasks for each workflow instance, performances are catastrophic, that why my idea was to update workflow instance properties (adding a task summary to these properties) to avoid task query on each workflow instance.
Then two questions:
- Would you have any advise to do that ?
- Why task queries performances are so poor ? Known issue ? Misconfiguration on my side ?
Thanks,
Vincent
08-03-2018 09:02 AM
You can still have a summary property on the workflow instance - you just need to set it from within the workflow itself using Activti APIs, not using the Alfresco WorkflowService.
I don't know why specifically the task queries would be slow for you - I've never had issues with those myself. You may have a badly optimised database, excessive query conditions, complex user-group relations (in case you are dealing with pooled tasks), or just too many tasks per workflow itself.
08-03-2018 09:24 AM
Axel, when you say
"You can still have a summary property on the workflow instance - you just need to set it from within the workflow itself using Activti APIs, not using the Alfresco WorkflowService."
Do you mean I can set and update a process variable with task summary information ?
In this case, how to access this variable from outside the workflow (WebScript) ?
Thanks for clarification..
VIncent
08-06-2018 03:17 AM
In particular, could you share an example of 'setting it from within the workflow itself using Activti APIs'
Thanks in advance :
08-06-2018 03:34 AM
I shouldn't need to provide examples for this when the core engine and its APIs have been documented quite extensively, i.e. in the User Guide. So when you have a TaskListener / ExecutionListener, all you need to do is use the provided execution to set variables on it. The only thing to keep in mind is that
08-06-2018 03:46 AM
OK thanks Axel. Last thing (to achieve my initial target): could you please confirm that when setting process instance properties this way, these properties will become accessible from Alfresco WorkflowService ?
08-06-2018 10:44 AM
They become accesible from the WorkflowService provided they have been defined in the model of the start task, which Alfresco uses to determine which variables get mapped in the API. I usually use a lot of aspects with optional properties for this, set on my start task via mandatory-aspects.
08-06-2018 10:49 AM
Great ! I'll test this and post here results. Thanks again.
Explore our Alfresco products with the links below. Use labels to filter content by product module.