Forums

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

set a specific time and add 1 day to a date field in a certain condition

אריג' חמדאן January 20, 2019
Hi,

my target field is "start date".
i need to calculate this:
if my issue's created date is= 18:30<CREATED date="">&lt; 00:00, it should set created date + 1 day and set the time at 8:00
else it should set just created date at 8:00
i need all that without skippingweekend

is it possible with behaviour expression boolean postfunction?

thanks for the help,
best regard
Arige</CREATED>

2 answers

0 votes
arige hamdan January 21, 2019

Hi

Thanks for the response and the help.

After adding your script to my script create transition, I get this error:

In addition, I need this if in your script:

18:30<CREATED date< 00:00

I need also an else in your script:

else it should set just created date at 8:00

 

can you please see send me a new one.

Thanks a a lot for assisting me!

 

 script calculated field date.png

Alexey Matveev
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.
January 21, 2019

You ve got the ScriptRunner add-on. But I gave a script for the Power Scripts add-on:

https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview

I do not have a script for ScriptRunner.

arige hamdan January 21, 2019

thx

that won t help me cause i have a sriptrunner add-on

 

thx again

Alexey Matveev
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.
January 21, 2019

You are most welcome!

0 votes
Alexey Matveev
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.
January 20, 2019

Hello,

You would need a plugin for it.

For example, you could use the Power Script add-on:

https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview

Your code would look like this:

#{Start Date} = created + "1d";

You can implement any logic you need in this code.

אריג' חמדאן January 21, 2019

Thanks for the response.

Can you assist me with writing the right code because i am not familiar with scripts.

How can i add my "if" to your code?

Thx a lot for the help

Alexey Matveev
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.
January 21, 2019

Your script will be like this:


if ( (hour(created) == 18 && minute(created) >= 30) || (hour(created) > 18)){
    date startDate = created + "1d";
    #{Start Date} = toDate(year(startDate), month(startDate), day(startDate), 8, 0, 0);
}

Suggest an answer

Log in or Sign up to answer