Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Restricting a page to be subjected to workflow only once at a time in AEM 6.3

Avatar

Level 3

Hi,

I want to restrict the AEM page to be subjected to workflow to only once. Means if I have started the workflow for a particular page I should not be allowed to start any other workflow until the workflow is completed/aborted. I can see this is happening in classic UI by default but in touch ui I was able to start multiple workflows at a time in workflow . How can I restrict in Touch Ui so that if once user starts the workflow no other user or himself can start the workflow until previous workflow is aborted/completed.  Please note I am working in AEM 6.3

Thanks in Advance

12 Replies

Avatar

Level 2

I'd be keen to know this also. Has anyone managed to get this to work? I think this is customisation...

Avatar

Level 10

By default - you can only have 1 workflow running on a given page.

Avatar

Level 2

We are finding that not to be the case. I just verified that too on a 6.3 SP2 instance on my local machine. Some of the others have tested this on 6.3 SP1. Have a look at the attached screenshot that shows the community page is being workflowed twice.

1page-2wf.jpg

Thoughts?

Avatar

Level 10

YOu are correct -- from the Classic UI - you can only subject a page to 1 workflow --

PageWF1.png

But in Touch UI - this is not the case. I will check with the team why these behaviors are not consistent.

Avatar

Level 2

Correct. That appears to be the case. I feel in general, there is a case that a page, at the very least, not being subject to multiple running workflows. That should be pretty simple to implement in Touch UI. It gets interesting when we talk about a workflow package where multiple resources are involved. Implement this kind of simple control for a package is that one could have multiple packages where the same resources participate. As you can imagine, with it being possible to subject a "page" to multiple workflows simultaneously is causing challenges to our authors. Our finding shows the following:

  1. Whichever version of the page via the workflow is actually published first, is the one that remains.  This is regardless of the order in which it may have been submitted into the workflow
  2. Whilst an author can submit multiple versions of the same page into a workflow, we did not encounter any bugs
  3. As well as the system preventing a page from being workflowed simultaneously, the should display a visual indicator for a page already being subject to a running workflow it is selected in Touch UI (in Column, Card or List views).

Shall we raise this as a bug with Daycare?

Thanks,

Arup

Avatar

Level 10

I just talked to the Workflow Eng team. There is no restriction at the Workflow level. The restriction we see in the Classic UI is at the UI level. So Classic has it and Touch UI does not. As far as the AEM Workflow engine is concerned - it can have the same page as payloads in multiple workflows. Hope this clears it up.

Avatar

Level 2

Thanks for the clarification. What is the use case for it from an "approval" point of view? Surely the end goal, for majority of the use cases, is to have several stages of reviews followed by activation to publish instance(s). What benefit could there possibly be in having multiple workflows for the same page? I just do not see the merit of it... What is your view?

Avatar

Level 10

Personally - I agree. You raise valid points - if you are routing a page through a workflow - there should only be 1 page.

Avatar

Community Advisor

Hi,

There is a way to identify whether page is part of workflow or not.

On click of create workflow , you can call js which check the workflow status using 'resource-status'

Screen Shot 2018-09-28 at 1.06.37 AM.png

e.g. for content/AEM63App/fr

http://localhost:4502/resource-status/editor/content/AEM63App/fr.1.json 

If page is part of workflow it returns response something like below:

{"0":{"statusType":"workflow","statusPriority":10000,"shortMessage":"demo-email","variant":"info","i18n.message.snippets":["demo-email"],"title":"Workflow","message":"This page is subject to the workflow <i>{0}<\/i>"}}

based on response you can stop further processing to go on launch workflow screen and return error using coral alert dialog.

I didn't try this but It can be feasible.



Arun Patidar

Avatar

Level 2

Thank you Arun. That certainly seems feasible. I still think this could be and should be a configurable behaviour within AEM. But yes, meanwhile, I think one has no option but to customise.

Avatar

Community Advisor

So I gave a try for this. I am bad in Jquery. Would love if somebody good at Jquery or UI can fix this . I tested this in browser console and it prevented a new workflow from initiating. Thanks to arun for the hints.

$(function() {

console.log("ready!");

var obj = $("button[title|='Start Workflow']");

var path = obj[0].dataset.path;

console.log(obj[0].dataset.path);

path = "/resource-status/editor" + path + ".1.json";

console.log("path is " + path);

var start = $(".js-cq-WorkflowStart-submit.coral3-Button.coral3-Button--primary");

console.log(start);

start.click(function(event) {

//event.preventDefault();

        event.stopPropagation();

// Do something

alert("clicked");

$.get(path, function(data) {

$(".result").html(data);

console.log(data);

//var jsonObject= JSON.stringify(data); var count = JSON.parse(jsonObject).length;

length = Object.keys(data).length;

if (length > 0) {

                var dialog = document.querySelector('.js-cq-WorkflowStart');

console.log(dialog)

                dialog.hide();

                var dialog = new Coral.Dialog().set({

                    id: 'myDialog',

                    header: {

                        innerHTML: '<coral-alert-header>Workflow cannot be started</coral-alert-header>'

                    },

                    content: {

                        innerHTML: '<coral-alert-content>Workflow cannot be initiated as the page has an active workflow already running. <br> Please complete the workflow before starting a new one</coral-alert-content>'

                    },

                    footer: {

                        innerHTML: '<button is="coral-button" variant="primary" coral-close>Ok</button>'

                    }

                });

                document.body.appendChild(dialog);

                dialog.show();

}

});

});

});

Avatar

Community Advisor

here you go:

create clientlibs with category 'cq.gui.coral.common.admin.timeline'

aem63app-repo/wfcheck.js at master · arunpatidar02/aem63app-repo · GitHub

Above code will check workflow initiation when you click from site console. This works for multipage as well.

The alert will show the page with workflow name and workflow instance's CRXDE location(if available) to help to locate workflow.

Screenshot 2018-10-08 at 12.48.22 AM.png

Screenshot 2018-10-08 at 12.48.35 AM.png

Note : Veena_07 shared the code which created to trigger check when you start workflow from page settings, similar code(or code reference from Veena ) can be written if want to restrict workflow for here as well.

Screenshot 2018-10-08 at 12.58.23 AM.png



Arun Patidar