Is there any way to achieve the below requirement.I would be grateful for your prompt reply.
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?
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,
We can create one separate workflow model for handling review process + scheduled activation.
Original workflow which is triggered on a document will capture the resources to be activated and for handling the validation and hence to activate by calling workflow model created above.
To locate the resources to be activated to the workflow:
Create dialog participant step with Touch UI dialog having pathfield as multifield resource.
For validations on resources and hence activate:
Create a process step which will perform the below
Get the list of resources(configured in dialog participant step) from the history. (WorkItem's MetaDataMap)
For each of the resources (via iteration)
Adapt the resource to a Page to check if the page is in locked state -> page.isLocked() #11
Using WcmWorkflowService(com.day.cq.wcm.workflow.api.WcmWorkflowService), check if the resource is already in workflow -> wcmWFService.isInWorkflow(resource path) #10
If both the validation is through(as indicated by a flag variable), trigger workflow using wfSession.startWorkflow(wfModel, wfData)
wfModel -> Create WorkflowModel object from separate workflow model (created for review and scheduled Activation process step)
wfData - Create WorkflowData with resource path which is through both the validation.
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
Workflow is triggered on a document (which has inputs to create pages)
Assigned to Content Author(Dialog Participant Step) -> Performs authoring/manual activity outside WF and completes the step by providing list of resources in dialog
Process Step -> custom process step performing above mentioned actions. (Another workflow model will be called for each of the validated resources)