Expand my Community achievements bar.

SOLVED

Replication action from workflow

Avatar

Level 5

Hi Team,

 

Is it possible to get a replication action from triggered workflow (activate page/assets model or activation model). 

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @AEMLearner-1989 

Yes, it is possible to get a replication action from a triggered workflow. When a workflow is triggered to activate a page or asset, it goes through a series of steps, including replication.

To get the replication action from the workflow, you can use the Workflow API provided by AEM.
you can retrieve the replication action from a workflow:

 

import com.adobe.granite.workflow.Workflow;
import com.adobe.granite.workflow.WorkflowData;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowExecutionContext;
import com.adobe.granite.workflow.metadata.MetaDataMap;

public class ReplicationActionWorkflowProcess implements WorkflowProcess {

    @Override
    public void execute(WorkItem workItem, WorkflowExecutionContext context, MetaDataMap args) throws WorkflowException {
        WorkflowData workflowData = workItem.getWorkflowData();
        String payloadPath = workflowData.getPayload().toString();

        // Check if the payload is a page or asset
        if (payloadPath.startsWith("/content/dam")) {
            // Get the replication action from the workflow metadata
            String replicationAction = workflowData.getMetaDataMap().get("replicationAction", String.class);

            // Do something with the replication action
            if (replicationAction != null) {
                // Perform specific actions based on the replication action
                if (replicationAction.equals("Activate")) {
                    // Handle activate action
                } else if (replicationAction.equals("Deactivate")) {
                    // Handle deactivate action
                }
            }
        }
    }
}

 


https://adobe-consulting-services.github.io/acs-aem-commons/features/workflow-processes/replicated-b... 
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/operations/replicat... 



View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi @AEMLearner-1989 

Yes, it is possible to get a replication action from a triggered workflow. When a workflow is triggered to activate a page or asset, it goes through a series of steps, including replication.

To get the replication action from the workflow, you can use the Workflow API provided by AEM.
you can retrieve the replication action from a workflow:

 

import com.adobe.granite.workflow.Workflow;
import com.adobe.granite.workflow.WorkflowData;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowExecutionContext;
import com.adobe.granite.workflow.metadata.MetaDataMap;

public class ReplicationActionWorkflowProcess implements WorkflowProcess {

    @Override
    public void execute(WorkItem workItem, WorkflowExecutionContext context, MetaDataMap args) throws WorkflowException {
        WorkflowData workflowData = workItem.getWorkflowData();
        String payloadPath = workflowData.getPayload().toString();

        // Check if the payload is a page or asset
        if (payloadPath.startsWith("/content/dam")) {
            // Get the replication action from the workflow metadata
            String replicationAction = workflowData.getMetaDataMap().get("replicationAction", String.class);

            // Do something with the replication action
            if (replicationAction != null) {
                // Perform specific actions based on the replication action
                if (replicationAction.equals("Activate")) {
                    // Handle activate action
                } else if (replicationAction.equals("Deactivate")) {
                    // Handle deactivate action
                }
            }
        }
    }
}

 


https://adobe-consulting-services.github.io/acs-aem-commons/features/workflow-processes/replicated-b... 
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/operations/replicat... 



Avatar

Community Advisor

@AEMLearner-1989 : Yes it possible to do this but there are multiple ways to it.

  1. You can add OOTB workflow 'Activate Page' to your custom WF and once your custom WF is done executing, the next step would be the OOTB workflow and that will publish your page. You can do the same for Assets as well. Please refer this for general guidance:- https://medium.com/@ganthisblog/aem-custom-workflow-scheduled-content-activation-31ddd092ef3f
  2. Other way is to pragmatically call the Activate Page WF model using the WF API. You will have to invoke the Activate Page/Asset workflow from your custom workflow process step. Please refer: https://aemsimplifiedbynikhil.wordpress.com/2020/11/13/invoking-a-workflow-from-servlet-in-aem-6-5-5...
    https://medium.com/@toimrank/aem-custom-workflow-process-step-56e176f8f067#e90d

thanks.

Avatar

Employee

 

To implement a replication action from a triggered workflow in Adobe Experience Manager (AEM), such as activating pages or assets, you will need to configure and customize your workflows accordingly. In AEM, replication is the process of making content available on Publish instances after it has been worked on in an Author instance. Workflows can be set up to include replication steps that automate this process when certain conditions are met, like the approval of a page or asset.

In AEM, the Request for Activation workflow is one such workflow that can be customized to include a replication step. This workflow is typically used for publishing pages within AEM Sites and is automatically triggered when a content author attempts to publish content but does not have the appropriate replication rights. To customize this behavior, you can overlay the workflow model and update related configurations and scripts as required. Here is a step-by-step process to customize the Request for Activation workflow for replication:

  1. In /apps, overlay the Sites wizard found at /libs/wcm/core/content/common/managepublicationwizard. This overrides the common instance from /libs/cq/gui/content/common/managepublicationwizard.
  2. Update the workflow model with the desired replication action and any related configurations or scripts that need to be adjusted.
  3. Remove the right to replicate from all users for relevant pages to ensure that this workflow is triggered as the default action when users attempt to publish content.

For more information on customizing the workflow for replication actions, please refer to the following AEM documentation:

Moreover, when developing custom workflows or steps that involve replication, you can utilize AEM's Replication API. This API allows you to programmatically perform replication actions within your custom workflow steps. The following documentation provides detailed information on using the Replication API:

Avatar

Administrator

@AEMLearner-1989 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni