Comala workflow in confluence - working with due date set up
Asked by Vanisree Valaboju:

I have a workflow set up as per below

Stage(Business case initiated) -\> Transition(Submit) -\> Stage(Primary Review)

Stage(Primary Review) -\> Transition(Approve) -\> Stage(Secondary Review)

Stage(Primary Review) -\> Transition(needs more info) -\> Stage(Revision I)

Stage(Secondary review) -\> Transition(Approve) -\> Stage(Business Case Final)

Stage(Secondary Review) -\> Transition(Need more info) -\> Stage(Revision II)

I added due date 5 days for stages Primary Review and 5 for Secondary review.

My question is when primary review says need more info then sue date has to stop and trigger back again from same time when moving back from Revision I to primary review.

Example lets say review is submitted today 10/21/2020 and as per above set up, this review will expire 10/26/2020. I login and say need more info on 10/23/2020 so I saved 3 days there which need to start back again when the revision I is moved to primary review and now I should only have 3 days to review instead of 5 days.

Can we achieve this USE CASE in comala workflow?

Appreciate your quick response.


Answers:
author: Matteo Gubellini _SoftComply_
body: Hello Vanisree,  
Yes you can.  
1) Save the due date of state in a variable. The system will save it as a date, not period.  
2) When the wf transitions back to the state with the due date, use the set-state-expiry macro and re-set the due date to the valued you saved before.

I used it a few times in my wfs and it works ok.

Matteo

comments: author: Vanisree Valaboju
body: Thank you Matteo for your quick response on this issue.

so if we create the variable Expire date = 5 days then with int he state if we give duedate set to variable then every time it enters the state will consider 5 days. but my requirement if it moves to revision I and then back to Primary review state then days left should be 3 instead of 5.

Hope this give clarity of my ask


author: Matteo Gubellini _SoftComply_
body: Hi Vanisree,

My approach is a bit different and it will solve you problem. See example below:

{trigger:statechanged\|state=Stage(Primary Review)\|@firsttimeinstate@=True}  
{set-metadata:duedateold}@expirydate@{set-metadata}  
{trigger}

{trigger:statechanged\|state=Stage(Primary Review)\|@firsttimeinstate@=False}  
{set-state-expiry:duedate=@duedateold@}  
{trigger}

{trigger:statechanged\|state=Stage(Revision I)}  
{set-metadata:firsttimeinstate}False{set-metadata}  
{trigger}

@firsttimeinstate@ has to be initialized to "True" at page creation, or anywhere before the Stage state


author: Vanisree Valaboju
body: Thank you Matteo, I appreciate your detail steps. Thank you again for all your help. I will keep you posted on my test results or issues once my end to end testing is complete.

Ok with your code above I set the below example and walked my self from each step and it works. but I will keep you posted on how my testing goes.

**Creation Date - 10/26/2020**

**@firsttimeinstate@ - True/False**

**@expirydate@ - 5 days (10/30/2020)**

**@duedateold@ - place holder to store @expirydate@@**

++**Step 1 -**++ When page gets created (Date 10/26/2020)

{trigger:pagecreated}  
{set-metadata:firsttimeinstate}True{set-metadata}  
{trigger}

++**Step 2 -**++ As per configuration or parameter set up @expirydate@ - 5 days (10/30/2020)

So when the page goes to stage (Primary Review) then it goes to below condition

{trigger:statechanged\|state=Stage(Primary Review)\|@firsttimeinstate@=True}  
{set-metadata:duedateold}@expirydate@{set-metadata}  
{trigger}

**At the end of step 2 -** @firsttimeinstate@ =True; @expirydate@ = 5Days (10/30/2020); @duedateold@=5ays (10/30/2020)

++**Step 3 -**++ After 2 days (10/28/2020), I will go to stage 'Revision I', at this stage the workflow goes into trigger 3.2. Then the values set are @firsttimeinstate@ = False

++***Trigger 3.1 -***++

{trigger:statechanged\|state=Stage(Primary Review)\|@firsttimeinstate@=False}  
{set-state-expiry:duedate=@duedateold@}  
{trigger}

++***Trigger 3.2 -***++

{trigger:statechanged\|state=Stage(Revision I)}  
{set-metadata:firsttimeinstate}False{set-metadata}  
{trigger}

++**Step 4 -**++ after 4 days (10/30/2020) if the step goes to Primary review this time the trigger 3.1 condition satisfies and then it says set-state-expiry:duedate=10/30/2020


author: Matteo Gubellini _SoftComply_
body: Only one comment, @expirydate@ retrieves the expiry date of the current step, you do not need to set it, it's read-only.

Basically, you set the due date of the Primary and Secondary reviews using the normal duedate option in the state.

`{state:Stage(Primary Review)|duedate=P5D}`` `

\<transition to other states etc.\>

`{state}`


Tags: confluence-server

server