1
votes

How to customize the cq5 workflow inbox message payload from a java class?

Basically i have a custom workflow for which have a launcher to trigger the workflow on nt:unstructured node creation. But i want to show the payload in the workflow inbox till the page path not to the JCR:content node. ( i am trying to have a process step after the workflow start and change the payload path of the inbox message through the java class and for the next participant step the inbox message should appear till the page path) .. Any idea help to change the workflow payload path at runtime in an process step .?

3
are you trying to add custom attribute/column in inbox? - Pakira
Nope i am trying to change the inbox message payload path and hyperlink for that payload path. - VAr
Did you change payload path? I also have this problem. - MastAvalons

3 Answers

1
votes

This seems like kind of a hacky way to solve this problem. The Workflow Launcher functionality is a little limited, as you can probably see in this case. But, what if you launch the workflow through different means?

I assume that if you are waiting for an nt:unstructured node to be created, then it's some operation like adding a component to a parsys. Specifically, I'm assuming this action is making a POST request, using the Sling default POST servlet to resolve. (Many of the basic AEM/CQ actions do this.)

How about registering a SlingPostProcessor or something that can listen for that operation to happen. In that code, you can do the work to "get the page", then use the WorkflowSession class (and its related API) to programmatically kick off a workflow instance.

With this approach you are programmatically kicking the workflow off with the correct payload, instead of trying to hack around the limitations of the Workflow Launcher interface, changing the payload, mid-workflow. This feels like a better approach to me.

0
votes

I had same issue. I am using CQ 5.5.

Sharing my experience, hope it will work for you.

You don't need to change the payload. The payload can remain as jcr:content

You need to do two things:

  1. Make sure the folder-path/jcr:content has the value in property jcr:title. It will be shown in content column of the inbox page.

  2. For the folder link in inbox page, it must be as /content//jcr:content. The problem is because /damadmin.html# is not added before the url.
    This problem is not coming for any Asset or Page.
    Solution is:
    You need add the following code in /libs/cq/workflow/components/inbox/list/json.jsp


A=> Add private method

private String handleDamPathForFolder(Logger log, String payloadUrl, Session session, WorkItem wi)
{
    try
    {
        if(isFolderNode(session, wi))
        {
            return ("/damadmin.html#"+payloadUrl);
        }
    }catch (Exception e)
    {
        log.error("Unable to handle path creation for work item: " + wi.getId(), e);
    }
    return payloadUrl;
}

You have to write the method isFolderNode which will return true if the node is a folder.



B=>Replace

JSONWriterUtil.write(writer, "payload", pathBuilder.getPath(wi),JSONWriterUtil.WriteMode.BOTH, xss);


by the follwoing


JSONWriterUtil.write(writer,"payload",handleDamPathForFolder(log,pathBuilder.getPath(wi), session, wi), JSONWriterUtil.WriteMode.BOTH, xss);

Enjoy!!!


PS: Modify method arguments as per your code.

0
votes

If you want to pragmatically modify the payload you have to create a new com.adobe.granite.workflow.exec.WorkflowData instance, then by calling the newWorkflowData method of the WorkflowSession you can specify ythe newly created payload. After this you also have to call the updateWorkflowData of the WorkflowSession to store the change. You can add this as a first step of the workflow if you want anyway to change the payload. If you only want to modify the inbox item, to add the ability for users to easily access the content and not the jcr:content node, you should check the redirect logic at: /libs/cq/workflow/components/workitem/loadPayloadUrl.jsp. Adding some extra logic to this will result that your users will be able to access the content when clicking on the payload of the inbox item.