Restricting a page to be subjected to workflow only once at a time in AEM 6.3 | Community
Skip to main content
Level 2
September 8, 2017

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

  • September 8, 2017
  • 2 replies
  • 9318 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Level 2
September 26, 2018

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

smacdonald2008
Level 10
September 26, 2018

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

Level 2
September 27, 2018

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.

Thoughts?

VeenaVikraman
Community Advisor
Community Advisor
October 6, 2018

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();

}

});

});

});

arunpatidar
Community Advisor
Community Advisor
October 7, 2018

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.

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.

Arun Patidar