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
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.
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
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.
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
In particular, could you share an example of 'setting it from within the workflow itself using Activti APIs'
Thanks in advance :
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
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 ?
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.
Great ! I'll test this and post here results. Thanks again.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.