Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Workflow branch based on tags via ECMA Scripts

Avatar

Level 2

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.

1 Reply

Avatar

Level 2

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";

}