Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

[AEMaaCS] Unlock page automatically after workflow termination

Avatar

Level 2

Hello guys ,

 

How can we unlock a page automatically just after its workflow is terminated manually ? 

 

thanks , 

Rahul Kumar

2 Replies

Avatar

Community Advisor

Are you using any custom workflow?

 

Generally to lock or unlock a page through code- 

// To Lock a page
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page page = pageManager.getPage("/content/myPage");
pageManager.lock(page);

// To Unlock a page
pageManager.unlock(page);

 

If you are using a custom workflow - you have to add workflow step:

 

@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {
try {
ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
String path = workItem.getWorkflowData().getPayload().toString();
Page page = pageManager.getPage(path);
if (page != null && pageManager.isLocked(page)) {
pageManager.unlock(page);
}
} catch (Exception e) {
throw new WorkflowException("Failed to unlock page", e);
}
}

Avatar

Community Advisor

Hi Both,

There is already OOTB Lock/Unlock Steps available, you can use that in order to lock page

 

Workflow Steps:

1. Workflow Initaite

2. Approval Step

3. Lock

4. Activate/Deactivate

5. Unlock

 

arunpatidar_0-1727274669109.png

 



Arun Patidar