Highlighted

Workflow branch based on tags via ECMA Scripts

davenichols79

07-06-2018

Hi,

Please can somebody help or point me in the right direction.  I'm creating some workflows for assets and setting up some "OR branches".  I have been using the example in ECMA Script on the Adobe documentation based on location of the asset, but I would really like to base the "or branches" on the tags that the asset has or if not possible then the meta data of the asset.

Is it possible to use ECMA Script to get the tags on the asset that the workflow is running on and can anybody please point me in the right direction to documentation or provide an example where ECMA Script is picking up the asset tags and checking for one ?

Thank you very much for your time.

Replies

Highlighted

davenichols79

28-06-2018

For anybody interested, we managed to do this using the script below.  Thanks.

function getParticipant() {

   

    var workflowData = workItem.getWorkflowData();

var path = workflowData.getPayload().toString();

    log.info(path);

    var node = workflowSession.getSession().getNode(path);

    var tagValues = node.getNode("jcr:content").getNode("metadata").getProperty("cq:tags").getValues();

    for (var i=0 ; i < tagValues.length; i++) {

        if(tagValues[i] == "global:test/testing") {

            return "Product Marketing";

        }else{

            return "Technical";

        }

    }

return "Product Marketing";

}