Forums

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

Scripted Date Field to calculate according to the dropdown list

Vikrant Yadav
Community Champion
December 11, 2020

Hi Guys,

 

Need your help in order to calculate to Date according to the dropdown list and date field. 

If A ( dropdown list) = XYZ and Target Date = 10/12/2020, then Scripted date field would be 1st of the month like 01/12/2020.

 

If A (dropdown list) = LMN and Target Date = 15/12/2020 then Scripted Date field would be -20 of Target Date , like 25/11/2020

 

Please suggest, how can i achieve this, i have script runner plugin . 

I am thinking to do it via Escalation Service. PLease suggest. What's is the best solution. 

2 answers

0 votes
Nic Brough -Adaptavist-
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.
December 13, 2020

It'll be easiest to do this with a scripted field, not an escalation service.

A scripted field can be set up as a date/time field, so your code will simply have to read the two fields, do some simple calculations to work out the new date and return the date/time as the output.

There are a load of example scripts for looking up fields and working with dates over at https://library.adaptavist.com/search?page=1&products=jira&platforms=server&term=date

Vikrant Yadav
Community Champion
December 13, 2020

Hi @Nic Brough -Adaptavist-  Thanks for the help. 

I have tried to create a scripted date field " Target Release Date", which will set automatically according to the select list "Country" and date field "Audit Start Date". When country = India then Target Release date would be the next day of the Audit Start Date, for this i have added +1 I have tried to create a script but it not working. Showing error. Please suggest ...I am not sure how to do calculation in date field.Target Date.PNGScripted Date field.PNGError message.PNG

0 votes
Vikrant Yadav
Community Champion
December 13, 2020

Hi @Nic Brough -Adaptavist-  Please suggest on above query. 

Suggest an answer

Log in or Sign up to answer