Hi All,
Is there any way to achieve the below requirement.I would be grateful for your prompt reply.
Requirement:
1. Requester starts workflow in AEM assets by selecting a word or a pdf document. Requester also selects a schedule publish date/time.
2. Document has description for pages to be built in AEM.
3. Assigns the workflow to a content Editor to build pages from the steps in the document.
4. Content Editor builds pages in AEM and now wants to attach to the running workflow job.
5. Editor adds the files to the job and the workflow proceeds for review.
6. Reviewer could accept or send back review comments to Editor.
7. Editor makes changes and could potentially add/remove pages compared to what were in the first review cycle.
8. Approver approves the job and workflow proceeds to the publish step which is scheduled.
9. Workflow publishes the page when the time arrives.
10. Pages could already be in an active (running) workflow. When Authors attempt starting a new workflow with such pages, the workflow must end with an email (or some sort of notification) that the page attached to this workflow was found already being processed in another workflow.
11. Check for pages that are locked. If a workflow finds Editor has added a locked page to the workflow, then workflow should terminate itself with a notification to the Initiator/Requester/Editor.
Steps #5 & #7
Approach 1: Create a Workflow package manually and add/remove files from it manually.
Approach 2: Create Workflow package programatically and add/remove files from it programatically.
Approach 3: Create a Workflow package manually and add/remove files from it programatically.
Create a dialog participant step in the workflow to browse pages and update the workflow package programatically using Page API/Node API.
Suggest the best approach or any new way to achieve this?
Steps #10 & #11
Approach to achieve these senarios?
Solved! Go to Solution.
Hi @nandini559,
Below response is with respect to the requirement listed + validation required on the resources to be activated + possibilities with OOB Workflow set up.
For the query "attach pages to the running workflow" - This is not possible. This is because, the flow starts by triggering workflow on an Asset-> word or pdf document, which remains as Payload through out the Workflow and it is not possible to directly amend the Payload. (for our publish process step to act upon in the same workflow)
For this reason,
To locate the resources to be activated to the workflow:
For validations on resources and hence activate:
By this way, separate workflow instance will be created for each of the validated resources.
API for creating Workflow Package is not exposed as service OOB in which case, we can create single workflow instance pertaining to the workflow package path. (I will explore other options around this and update this thread)
In brief, below is the high level flow
Rough snippet from custom Workflow process step:
List<HistoryItem> historyItems = wfSession.getHistory(item.getWorkflow());
for (HistoryItem history : historyItems) {
MetaDataMap workItemMetaMap = history.getWorkItem().getMetaDataMap();
String[] pathFieldValues = workItemMetaMap.get("pathFieldMulti", String[].class); // pathFieldMulti holds the array of paths authored in Dialog participant step
if (null != pathFieldValues) {
for (String pathField : pathFieldValues) {
boolean wfFlag = true;
if (null != pathField) {
Resource pathResc = rescResolver.resolve(pathField);
Page pathPageObj = pathResc.adaptTo(Page.class);
if (null != pathPageObj) {
if (pathPageObj.isLocked()) {
wfFlag = false;
LOG.debug("Page is locked");
}
}
if (wcmWFService.isInWorkflow(pathField)) {
wfFlag = false;
LOG.debug("Page is in WF already");
}
if (wfFlag) {
WorkflowModel wfModel = getWorkflowModel(wfSession);
WorkflowData wfData = getWorkflowData(wfSession, pathField);
startWorkflow(wfSession, wfModel, wfData);
}
}
}
}
}
private void startWorkflow(WorkflowSession wfSession, WorkflowModel wfModel, WorkflowData wfData) {
try {
wfSession.startWorkflow(wfModel, wfData);
} catch (WorkflowException e) {
LOG.error("Unable to start workflow={}", e.getMessage());
}
}
private WorkflowData getWorkflowData(WorkflowSession wfSession, String pathFieldVal) {
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", pathFieldVal);
return wfData;
}
private WorkflowModel getWorkflowModel(WorkflowSession wfSession) {
WorkflowModel wfModel = null;
try {
wfModel = wfSession.getModel(ACTIVATION_WF);
} catch (WorkflowException e) {
LOG.error("Unable to create WF Model={}", e.getMessage());
}
return wfModel;
}
You can create a launcher which triggers the workflow when requester selects a word or PDF document and that workflow can be assigned to content editor for further processing.
See [0] for detailed information on launcher part.
[0]: https://helpx.adobe.com/experience-manager/using/Workflows.html#UsingWorkflowLauncher
Views
Replies
Total Likes
Hi @nandini559,
Below response is with respect to the requirement listed + validation required on the resources to be activated + possibilities with OOB Workflow set up.
For the query "attach pages to the running workflow" - This is not possible. This is because, the flow starts by triggering workflow on an Asset-> word or pdf document, which remains as Payload through out the Workflow and it is not possible to directly amend the Payload. (for our publish process step to act upon in the same workflow)
For this reason,
To locate the resources to be activated to the workflow:
For validations on resources and hence activate:
By this way, separate workflow instance will be created for each of the validated resources.
API for creating Workflow Package is not exposed as service OOB in which case, we can create single workflow instance pertaining to the workflow package path. (I will explore other options around this and update this thread)
In brief, below is the high level flow
Rough snippet from custom Workflow process step:
List<HistoryItem> historyItems = wfSession.getHistory(item.getWorkflow());
for (HistoryItem history : historyItems) {
MetaDataMap workItemMetaMap = history.getWorkItem().getMetaDataMap();
String[] pathFieldValues = workItemMetaMap.get("pathFieldMulti", String[].class); // pathFieldMulti holds the array of paths authored in Dialog participant step
if (null != pathFieldValues) {
for (String pathField : pathFieldValues) {
boolean wfFlag = true;
if (null != pathField) {
Resource pathResc = rescResolver.resolve(pathField);
Page pathPageObj = pathResc.adaptTo(Page.class);
if (null != pathPageObj) {
if (pathPageObj.isLocked()) {
wfFlag = false;
LOG.debug("Page is locked");
}
}
if (wcmWFService.isInWorkflow(pathField)) {
wfFlag = false;
LOG.debug("Page is in WF already");
}
if (wfFlag) {
WorkflowModel wfModel = getWorkflowModel(wfSession);
WorkflowData wfData = getWorkflowData(wfSession, pathField);
startWorkflow(wfSession, wfModel, wfData);
}
}
}
}
}
private void startWorkflow(WorkflowSession wfSession, WorkflowModel wfModel, WorkflowData wfData) {
try {
wfSession.startWorkflow(wfModel, wfData);
} catch (WorkflowException e) {
LOG.error("Unable to start workflow={}", e.getMessage());
}
}
private WorkflowData getWorkflowData(WorkflowSession wfSession, String pathFieldVal) {
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", pathFieldVal);
return wfData;
}
private WorkflowModel getWorkflowModel(WorkflowSession wfSession) {
WorkflowModel wfModel = null;
try {
wfModel = wfSession.getModel(ACTIVATION_WF);
} catch (WorkflowException e) {
LOG.error("Unable to create WF Model={}", e.getMessage());
}
return wfModel;
}
Hi @Vijayalakshmi_S Thanks a lot for the reply and there is one more question. As per my understanding here we are adding the resources to the multi-field and in the next step we are looping through the list and calling another workflow model on valid resources. But here if the reviewer sends back to modify the pages , can the editor be able to add/remove pages from the multi field(referring to step 6 and 7 from my question)? If so how to retain/get back the values which are stored in history to multi field in the dialog. Is this possible / any other way to achieve this reject scenario?
Views
Replies
Total Likes
Hi @nandini559,
Dialog that we are associating to a step in Workflow is specific to that step and is included in the Work Item via Dialog Injection.
We cannot retain the values on any further step having the same dialog.
Given this, review cannot be done on the list of resources as such. (as there is no means for the next step/participant to know the list of resources selected for activation)
That's why I have suggested to have review step + activation process in separate workflow model. In which case, review will happen on the individual resources.
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies