Forums

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

How to dynamically set a field based on another field value

Jessica Fergus June 12, 2018

I have a custom field called "Project Cost Performance Index" custom ID 12202

The values in this field are numeric and mean:

  • If CPI is less than 1, the task is over budget.
  • If CPI is one, the task is on budget.
  • If CPI is greater than 1, the task is under budget.

I have another custom field called "Project Cost Status" custom ID 12203

But I want it to populate the text status based on if the Project Cost Performance Indicator is less than 1 (Over Budget), is 1 (On Budget) and greater than 1 (Under Budget).

I can do this easily with an export to Excel and conditional formatting but want it all in JIRA.

Anyone help with the script to do this? I want to just add it to the Project Cost Status description field, right?

2 answers

1 accepted

1 vote
Answer accepted
Jessica Fergus June 12, 2018

I also have this plug-in that I used for the other custom fields that may do the trick: https://apps.decadis.net/display/JWT/Calculated+Text+Field 

0 votes
Scott Theus
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.
June 12, 2018
Jessica Fergus June 12, 2018

Possibly. I just am not good enough with script to parse out what I need. I don't want to do this post-function as this might change several times during the lifecycle of a task, and not necessarily just at transition.

Here is the thread that is closest to what I am trying to do, but it is pretty old and I am not sure of how to modify the script for my needs:

https://community.atlassian.com/t5/Jira-questions/Jira-set-a-field-based-on-another-field/qaq-p/445559 

Jessica Fergus June 12, 2018

I want to populate the Project Cost Status field with the text phrase .... "Over Budget", "On Budget", or "Under Budget" based on if the CPI in the Project Cost Performance Index field is less than, equal or greater than 1.

I think this is the script I need to modify for my situation (this one hides or displays a field based on another fields value instead of populating text in the field like I need):


<script type="text/javascript"> 
change = document.getElementById('customfield_10124'); 
if (change) { 
defect = document.getElementById('customfield_10171FieldArea'); 
defect.style.display='none'; 

change.onchange=function() { 

if (this.value == 'Defect') { 
defect.style.display='';
} else { 
defect.style.display='none';

}

----------------Where:
 I have a custom field called "Project Cost Performance Index" custom ID 12202 The values in this field are numeric and mean:

  • If CPI is less than 1, the task is over budget.
  • If CPI is one, the task is on budget.
  • If CPI is greater than 1, the task is under budget.

I have another custom field called "Project Cost Status" custom ID 12203 But I want it to populate the text status based on if the Project Cost Performance Indicator is less than 1 (Over Budget), is 1 (On Budget) and greater than 1 (Under Budget). 

Suggest an answer

Log in or Sign up to answer