Expand my Community achievements bar.

SOLVED

Add property to DAM Asset metadata using custom workflow

Avatar

Level 6

How to access the metadata node to add additional property on DAM UPDATE ASSET using custom workflow?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can get required details like below

//Get session

Session session = workflowSession.getSession();

// Get the Workflow data (the data that is being passed through for this work item)

final WorkflowData workflowData = workItem.getWorkflowData();

// Get the path to the JCR resource from the payload

        final String payloadPath = workflowData.getPayload().toString();

        ResourceResolver resourceResolver = null;

        try {

            // Get the ResourceResolver from workflow session

            resourceResolver = getResourceResolver(workflowSession.getSession());

            Resource resource = resourceResolver.getResource(payloadPath);

            // Using resource, we can read/update/add properties to required node by adapting to node or iterating to the required node and save the node by using session

        }catch(Exception e){

        // Add appropriate logger statements for checking errors

        }

Hope this helps!

View solution in original post

3 Replies

Avatar

Community Advisor

Hi,

For adding custom properties to asset meta data, we need to add custom workflow process step to "Dam Update Asset" workflow.

Go to /libs/settings/workflow/models/dam/update_asset.html ,edit the workflow model ,add Process Step component and select your custom process step and save it.

For creating custom workflow, you can refer below

https://helpx.adobe.com/experience-manager/using/message_service_gateway_api_64.html

http://www.6dglobal.com/blog/creating-custom-CQ-workflow-process-step-2014-10-14

Avatar

Level 6

I created a process, added it to DAM UPDATE ASSET and it's all working fine. What I'm troubling with is how to access the metadata node in the execute() method to add properties to it.

Avatar

Correct answer by
Community Advisor

You can get required details like below

//Get session

Session session = workflowSession.getSession();

// Get the Workflow data (the data that is being passed through for this work item)

final WorkflowData workflowData = workItem.getWorkflowData();

// Get the path to the JCR resource from the payload

        final String payloadPath = workflowData.getPayload().toString();

        ResourceResolver resourceResolver = null;

        try {

            // Get the ResourceResolver from workflow session

            resourceResolver = getResourceResolver(workflowSession.getSession());

            Resource resource = resourceResolver.getResource(payloadPath);

            // Using resource, we can read/update/add properties to required node by adapting to node or iterating to the required node and save the node by using session

        }catch(Exception e){

        // Add appropriate logger statements for checking errors

        }

Hope this helps!