Search code examples
javaworkflowsharealfrescoecm

How to Retrieve Aspect Value in Alfresco/Activiti Workflow


In the course of my workflow, I want to be able to set a variable using a document aspect. Now I know to set a variable using the property of a document I would do something like...

task.setVariable('wf_caseType', bpm_package.children[0].properties["hearing:caseType"]);

And that's just based on looking at the Alfresco Javascript API. However, I have not seen anything on retrieving the aspect of a document.

What I've done so far is in some javascript that gets executed when a file is brought over to a certain space, we create this aspect called caseID similar to below..

var caseID=0

var props=new Array(1);
props["wf:caseIDNum"]=caseID;
var newAspect=newNewSpaceName.addAspect("wf:caseID",props);

And what that does is basically add the caseID aspect to the folder that gets created in the script, and subsequently the documents within that folder also inherit this aspect.

So I was thinking adding that to a variable might work the same way, i.e:

task.setVariable('wf_caseId', bpm_package.children[0].aspect["hearing:caseId"]);

However, that has proved to not be the case. Does anyone have any experience doing this or perhaps could offer some advice here?


Solution

  • When an aspect has been added to a node, you can get/set any of its properties like you would any of the properties defined by the node's content type. There is no difference. So your first setVariable call would work whether hearing:caseType is defined in a type or an aspect.