Expand my Community achievements bar.

SOLVED

Multi Payload Workflow

Avatar

Level 3

Hi,

 

We have a content fragment, and there are multiple content fragments referred to within this content fragment. I have a workflow that runs on the content fragment. Now, when a workflow is triggered on the main content fragment, I need to run the workflow on the main content fragment and also on all the referenced content fragments within it. The workflow involves multiple groups reviewing and approving the content. What is the feasibility of reviewing multiple payload previews within a single workflow for the review/approval process?

 

TIA.

@EstebanBustamante  @arunpatidar  

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Divya_T13 

 

Multiple payloads are not supported. It can only be one.

 

If you want to keep the related ones together, Maybe you should try exploring:


Aanchal Sikka

View solution in original post

11 Replies

Avatar

Correct answer by
Community Advisor

@Divya_T13 

 

Multiple payloads are not supported. It can only be one.

 

If you want to keep the related ones together, Maybe you should try exploring:


Aanchal Sikka

Avatar

Level 3

Hi @aanchal-sikka / @AmitVishwakarma 

 

Is there any feature/actual example where I can see on how this Workflow Package works?

Avatar

Community Advisor

Avatar

Community Advisor

Hi @Divya_T13 ,

In Adobe Experience Manager (AEM), the out-of-the-box (OOTB) workflow capabilities do not inherently support the automatic processing of referenced Content Fragments (CFs) within a primary CF.

To achieve the desired functionality, where triggering a workflow on a main CF also initiates workflows on all its referenced CFs, A custom solution is necessary.

You can develop a custom workflow process step that performs the following actions:

Identify Referenced Content Fragments:

Utilize AEM's AssetReferenceSearch API to programmatically search for and identify all CFs referenced within the main CF.
Initiate Workflows on Referenced CFs:

For each referenced CF identified, programmatically start the desired workflow, ensuring that each fragment undergoes the necessary review and approval processes.

Regards,

Shiv Prakash

Avatar

Level 3
I am utilizing AssetReferenceSearch API to retrieve referenced content fragments.When I execute a workflow on the main content fragment, it includes a process step where I use this API to obtain the referenced content fragments. However, when I programmatically initiate another workflow on these referenced content fragments, the initiator appears as workflow-process-service. 
 
I would like to start the workflow as initiator.I have multiple users who can initiate the workflow, so giving permissions to individual users is not applicable here. Any help is appreciated.
 
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
String initiator = workItem.getWorkflow().getInitiator();
        LOG.info("WF Initiator {} ", initiator);
        WorkflowData workflowData = workItem.getWorkflowData();
        String payloadPath = workflowData.getPayload().toString();
 
        try (ResourceResolver resourceResolver = ResourceResolverUtils.getDefaultServiceResourceResolver(resourceResolverFactory)) {
            Resource resource = resourceResolver.getResource(payloadPath);
            if (resource != null) {
                List<String> referenceList = new ArrayList<>();
                Node jcrNode = resource.adaptTo(Node.class);
                AssetReferenceSearch search = new AssetReferenceSearch(jcrNode, CoreConstants.DAM_ROOT_PATH, resourceResolver);
                Map<String, Asset> result = search.search();
 
                WorkflowModel workflowModel = workflowSession.getModel("/var/workflow/models/custom-approval-workflow");
 
                for (String key : result.keySet()) {
                    Asset asset = result.get(key);
                    referenceList.add(asset.getPath());
                    WorkflowData wfData = workflowSession.newWorkflowData("JCR_PATH", asset.getPath());
                    workflowSession.startWorkflow(workflowModel, wfData);
                }
                LOG.debug("Reference List {}", referenceList);
            }
        } catch (Exception e) {
            LOG.error("Error during workflow execution", e);
        }
}
 

Avatar

Community Advisor

@Divya_T13 

 

One option could be to use a Service User that can impersonate as the initiator & then trigger the new workflows.


Aanchal Sikka

Avatar

Level 3

Hi @aanchal-sikka 

 

I tried impersonating the service user as the initiator, but it didn't work. I obtained 'admin' user session and impersonated using the admin resolver (since the admin user can always impersonate all users) as mentioned in the link below, and it worked.

https://stackoverflow.com/questions/78188262/aem-custom-workflow-step-how-to-get-resourceresolver-fo...

Thank you for all your input.

Divya_T13_0-1739879407621.png

 

Avatar

Community Advisor

@Divya_T13 

 

admin sessions in general are not recommended. There is a config to accept these special cases in 6.5, not sure how acceptable they are on cloud.

 

For Service user, did you configure the service user as the impersonator and then impersonate via code?

aanchalsikka_0-1739881300961.png

 


Aanchal Sikka

Avatar

Community Advisor

@Divya_T13 

There is No OOTB feature that support multiple workflow

  • AEM workflows typically operate on a single payload (i.e., a single resource such as a Content Fragment).
  • The Inbox Task UI in AEM shows the current payload but does not natively support previewing multiple payloads.
  • If the approval process involves different groups reviewing different referenced Content Fragments, it may become complex.

Single Workflow with a Custom Step for Referenced CF Previews

  • Instead of separate workflows, collect all referenced CFs into a single payload preview:
    • Modify the workflow dialog UI to display multiple CFs.
    • Store paths of all referenced CFs in a multi-value metadata property.
    • Create a custom workflow step to render all referenced CFs within a single approval UI.
    • Use a custom preview panel in the AEM Inbox UI.

Pros:

  • Single workflow instance.
  • One consolidated approval process.
  • Reduces the number of workflow instances.

Cons:

  • Requires customization in AEM’s workflow UI.
  • Reviewers may need a custom interface to preview multiple CFs.

 

Avatar

Community Advisor

Hi @Divya_T13 

You can only achieve this by using workflow package similar to manage workflow with multi items.



Arun Patidar

Avatar

Level 7

Multiple payloads in a single workflow are not supported out-of-the-box. You can manage referenced content fragments (CFs) by:

1. Using Workflow Packages: Group related CFs into a package and trigger workflows on them.
2. Using Tasks & Projects: Manage related content using projects to handle approval separately.
3. Custom Solution: Develop a custom workflow process step to initiate workflows for referenced CFs using the AssetReferenceSearch API.

Each referenced CF would require separate handling or custom development to review them together.