Expand my Community achievements bar.

SOLVED

Scheduling activation on custom workflow

Avatar

Level 4

Dear community fellows,

 

I am now creating a workflow with scheduling activation function and I mainly refered to these:

Configure Schedule Publish in Content Approval Workflow 

&

Scheduled activation with workflows 

 

accoding to the reference above, I added three processes/steps on my workflow:

YuSheng_4-1667473055325.png

 

1. Dialog Participant Step (this is to introduce in datepicker and set activation date on payload page)

2. Process Step which captures the date value and sets it to workflow instance metadata property (absoluteTime)

3. Participant Step (Waiting for activation) set timeout "Immediate" and Timeout handler "Absolute Time Auto Advancer",

so the step will wait until the scheduled time is reached and proceed to the next step.

 

1 and 2 worked fine and I did set the absoluteTime on my workflow instance metadata:

 

YuSheng_0-1667471598842.png

 

However, the workflow keeps running without getting into step 3.

Take OOTB scheduled_activation workflow as an example,

after triggering, the workitem node shows the current step is "Waiting for activation"

 

YuSheng_1-1667472224846.png

 

But there is nothing under my workitems, means the workflow didn't proceed to "Waiting for activation" step.

 

YuSheng_2-1667472642794.png

 

Should I re-arrange workflow processes/steps or can I programmatically make the step proceed?

Any thoughts are welcome

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@YuSheng 

 

Did you check the Handler Advance in process step?

Ganthimathi_R_0-1667489289755.png

 

View solution in original post

4 Replies

Avatar

Level 5

@YuSheng  - Change the sequence of workflow and Approval Process add absoluteTime to workflowData....

manjunathdj_0-1667477954116.png

 

 

item.getWorkflowData().getMetaDataMap().put("absoluteTime", millis); 

 

Avatar

Level 4

@manjunathdj Thanks for the reply

 

I did add "absoluteTime" successfully to the workflow metadata (code snippet below), but it did not proceed to participant step (waiting for activation). it seems there is a breach between my Process Step (sets absoluteTime property) and Participant Step (waiting for activation).

 

I tried swapping Waiting for activation and Approve content like you suggested, but it didn't work.

 

The reason I put Approve content under Waiting for activation is that I hope the approver see the content only when schedule date is due.

 

YuSheng_1-1667486331997.png

 

ResourceResolver resolver = workflowSession.adaptTo(ResourceResolver.class);
Resource payloadResource = resolver.getResource(payloadPath + "/jcr:content");
ValueMap resourceValueMap = payloadResource.getValueMap();

Calendar calendar = (Calendar) resourceValueMap.get("scheduleddate",Calendar.class);
workItem.getWorkflowData().getMetaDataMap().put("absoluteTime",Long.valueOf(calendar.getTimeInMillis()));

Avatar

Correct answer by
Community Advisor

@YuSheng 

 

Did you check the Handler Advance in process step?

Ganthimathi_R_0-1667489289755.png