Triggering workflow when specific attribute is added
hi,
there is a workflow start event as “asset attribute added”. is there a way to limit the trigger of workflow when a particular attribute is added. i don’t want the workflow to be triggered for all the attributes, only for a particular attribute.
regards
Anie
Former User
Posted 5 years ago · Edited 1 year ago·Last reply 5 years ago
3 comments
rostislav
·5 years ago · EditedHi Anie,
We have a tutorial about how to start a workflow when a definition is added, which comes with an example workflow and a note:
Kind regards,
Rostislav
maximiliencote
·5 years ago · EditedHi everyone,
I just stumbled on this very nice article. Is there any (short) way to get the value of the modified attribute value ? (i.e, without launching a full query with the changedAttributeId, and the item.id of the asset to retrieve the value of the attribute ?)
Thanks
pmahend3
·5 years ago · EditedHi Anie,
The DGC currently doesn’t support the feature you’re looking for. However, you could get around this, we can write a simple script to use the Event bean’s getEventResourceId() method to get the AttributeId that triggered the workflow. This is a really helpful method as it returns the Uuid of the specific element that triggered the corresponding element and can be used in differing contexts. We can then get the corresponding attribute type from this value and check if you’d like to continue on with the workflow.
So leave the asset attribute added trigger as is and then your first script can be something like below.
boolean continueWorkflow = false;
requiredAttributeTypeId = string2Uuid(‘00000000-0000-0000-0000-000000003114’)
changedAttributeId = event.getEventResourceId()
changedAttributeTypeId = attributeApi.getAttribute(changedAttributeId).getType(),getId();
if(changedAttributeTypeId.equals(requiredAttributeTypeId)){
event.setVariable(“continueWorkflow”, true)
}
In the above code, I want a change in an asset’s definition attribute to trigger the workflow. Hope this helps.