cancel
Showing results for 
Search instead for 
Did you mean: 

Update custom fields during workflow progression.

tchenm1
Champ in-the-making
Champ in-the-making
Hi!

I created a content model type that created custom meta-data fields added to a folder detail form. I would like to update those fields during a workflow progression. Is that possible? If so, please forward me the link to the information or a sample bpmn that accomplishes a similar task.

Thanks!

Mike Tchen
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
There are two options.
Either you can do it via action classes.

or
using Script in the Process definition file.


<task-node name="rejected">
       <event type="node-enter">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                   for (var i = 0; i &lt; bpm_package.children.length; i++)
                   {
                      bpm_package.children.properties["wfl:status"] = "Draft";
                      bpm_package.children.save();
                   }
               </script>
           </action>
       </event>

       <task name="wf:rejectedTask" swimlane="initiator" />
       <transition name="" to="end" />
   </task-node>

tchenm1
Champ in-the-making
Champ in-the-making
I assume this process definition file is for the jBPM workflow. Do you have an equivalent for the Activiti workflow? Many thanks!

tchenm1
Champ in-the-making
Champ in-the-making
This is what I went with, I hope it helps others.

Within my user task of the Activiti model, I created a listener with the below configurations:

Event: complete
Type: Alfresco script
Script:
//finds document associated to the workflow
var document = bpm_package.children[0];
//finds the parent folder of where the document is located, the folder also contains custom fields I want to populate
var parentFolder = document.parentAssocs["cm:contains"][0];
//Set two custom field folder properties. sourceSubPerson doesn't work, but I will try to resolve that.
parentFolder.properties["sop:sourceSubmitted"] = new Date();
parentFolder.properties["sop:sourceSubPerson"] = "Bautista";
//Save the changes
parentFolder.save();