Multi Payload Workflow | Community
Skip to main content
Level 3
February 10, 2025
Solved

Multi Payload Workflow

  • February 10, 2025
  • 5 replies
  • 1615 views

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  

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

@divyat3 

 

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

 

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

5 replies

aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
February 10, 2025

@divyat3 

 

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
DivyaT3Author
Level 3
February 11, 2025

Hi @aanchal-sikka / @amitvishwakarma 

 

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

Shiv_Prakash_Patel
Community Advisor
Community Advisor
February 10, 2025

Hi @divyat3 ,

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
DivyaT3Author
Level 3
February 14, 2025
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);
        }
}
 
aanchal-sikka
Community Advisor
Community Advisor
February 17, 2025

@divyat3 

 

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

Aanchal Sikka
Jagadeesh_Prakash
Community Advisor
Community Advisor
February 10, 2025

@divyat3 

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.

 

arunpatidar
Community Advisor
Community Advisor
February 10, 2025

Hi @divyat3 

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

Arun Patidar
AmitVishwakarma
Community Advisor
Community Advisor
February 10, 2025

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.