Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Transition Post-Function Condition "Custom date" script

RKusmba
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2018

I would like to populate custom date in date field.

Custom date calculated as below

=IF(OR(WEEKDAY(Date)=3,WEEKDAY(Date)=4,WEEKDAY(Date)=5,WEEKDAY(Date)=6,WEEKDAY(Date)=7),(Date+7-WEEKDAY(Date)+2),IF(OR(WEEKDAY(Date)=1,WEEKDAY(Date)=2),(Date+7-WEEKDAY(Date)+4),"0"))

Any help on using this logic using post function "Script Post-Function" or "Scripted (Groovy) operation on issue (JMWE add-on)"

Thanks

1 answer

0 votes
David Fischer
Community Champion
August 1, 2018

Hi,

using JMWE, you can just use a "Set Field Value (JMWE add-on)" post-function and select "Groovy Expression" as the value type. Then for the value script, can you specify:

- what "Date" is: current date (now)?

- what WEEKDAY does: return the day of the week I suppose, but then what is WEEKDAY 1? Monday? Sunday?

RKusmba
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2018

Weekday expression mentioned is from excel. 1 - 7 as Monday through Sunday.

I am looking for some sample scripts to get started!

David Fischer
Community Champion
August 2, 2018

You didn't answer my other question about what "Date" means, so I'll assume the current date. You'll just need to update the first line if you meant something else.

Date date = new Date();
int day = date.day;
if (day==0)
day = 7;//Java/Groovy Sunday is 0
if (day >= 3)
return date + 7 - day + 2;
else
return date + 7 - day + 4;
RKusmba
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2018

Thanks David. Yes, Date above is the current date and time.

Suggest an answer

Log in or Sign up to answer