Forums

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

Scriptrunner Behavior to set Date Field based on another custom field select list?

Inayat Nahvi
Contributor
June 20, 2024

Hi,

We had this working in Data Center, and now I'm trying to rebuild in cloud.  Let me know if this possible.  Here's the scenario:

  • Customfield1 - this is a single select list.
  • Customdatefield2 - this is a custom date field.   (we used Due Date before, but apparently not supported in Scriptrunner cloud)

We would like to create this behaviour:

  • If Customfield1=A, set Customdatefield2 = today +3 days.
  • If Customfield1=B, set Customdatefield2 = today + 5 days.
  • If Customfield1=C, set Customdatefield2 = today + 7 days.

Is this possible in cloud Jira?

1 answer

0 votes
Sean Chua _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.
August 27, 2024

Hey @Inayat Nahvi ,

Have you tried using "Date Picker" custom field instead? Behaviours Cloud Supported Fields 

 

You should be able to do something like;
const selectedValue = Customfield1.getValue();

let daysToAdd = 0;

if (selectedValue === "A") {
    daysToAdd = 3; 
} else if (selectedValue === "B") {
    daysToAdd = 5; 
} else if (selectedValue === "C") {
    daysToAdd = 7; 
}

// Update the datepicker2 field with the new date
if (daysToAdd > 0) {
    const newDate = addDays(new Date(), daysToAdd);
    datepicker2.setValue(formatDate(newDate));
}
or something along those lines with the right functions.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events