cancel
Showing results for 
Search instead for 
Did you mean: 

Update WorkflowIntance property in Java

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi All,

Does anyone know how to update the WorkflowInstance property "description"?
Why the following code does not work?!! …


String newDescription = "something";
List<WorkflowInstance> contentWorkflows = workflowService.getWorkflowsForContent(documentRef, false);

for (WorkflowInstance workflow : contentWorkflows)
{
     workflow.description = newDescription;
}



Thanks in advance Smiley Happy

João
5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator
Hello,

the "description" property of the workflow instance object is purely read-only. Any changes to its value will not be saved back to the running workflow instance. In order to update the description, you need to update a process instance variable within the running instance in jBPM or Activiti - it usually can't be changed via the Alfresco Java API after the start task has been completed.
The variable is called "bpm_workflowDescription" and should be set in the top-most variable container of the process instance - Note that this change also may affect historical (completed) tasks, which may be shown with the updated workflow description (depending on variable lookup / resolution behavior).

Regards
Axel

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi Axel,

Thanks for the reply.

My goal is to change the description of all workflows (active and completed) for a given content.

How can I get the process instance to change the variable "bpm_workflowDescription"?

I want to change is value when the node is updated so I have crated a new behavior… I can update the tasks description:

<java>

for (WorkflowTask task : tasks)
{
     String taskId = task.getId();

     Map<QName, Serializable> params = new HashMap<QName, Serializable>();

     params.put(WorkflowModel.PROP_DESCRIPTION, newTasksDescription);
                 
     params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, newTasksDescription);
                 
     workflowService.updateTask(taskId, params, null, null);  
}

</java>

… but I don't understand how to get the process instance to change the workflow description…

Thanks again,

João

afaust
Legendary Innovator
Legendary Innovator
Hello,

you can't get the process instance via the Alfresco Java API - you can only access it from within a running workflow, i.e. via ExecutionLister / TaskListener (Activiti) or the jBPM equivalents of logic running in the workflow.

Regards
Axel

vinaxwater
Champ in-the-making
Champ in-the-making
Hi friend,

I don't change PROP_DESCRIPTION but I have change PROP_COMMENT and PROP_STATUS in flow of workflow process and it's work for me Smiley Very Happy
This is my code:

workflowService.updateTask("jbpm$"+taskId, params, null, null);


It's only deferent small with add string "jbpm$" into taskId.

Hope useful for you.

Hi vinaxwater,

Thanks for the tip.

I can update task properties. My problem is with workflow properties. The workflow description appears in document details. When the document metadata is updated it becomes incorrect because workflow description is based in document metadata.

I want to update this property in completed/active workflows. Every time a user updates the document metadata.

Any ideas?

Thanks again!

João