Forums

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

Set value of custom field based off of two fields (custom field and component)

Suzanne Matheu August 16, 2018

Here is the issue I am trying to solve for.  

Our team uses the "Component" field to represent a master project number. Each master project number has 12 sub-project numbers under it however these are not populated in the "Component" field. Based on the "Component" and the custom field "Release" you could look up the value for the sub-project number from an outside system, but this doesn't meet the needs of the team. They would like that information directly in JIRA so that we have one source of truth. The idea is to have a new custom field called "Sub-Project Number."

I'm trying to figure out if we can update the "Sub-Project Number" based off the "Component" and "Release" field values. Due to the number of Components, Releases and Sub-Project Numbers and the fact it will be changing regularly I can't imagine hard scripting it, but think instead we would need some sort of lookup table so the table could be updated versus the script and then the script would go look at the table.

As a note, we have ScriptRunner which I am quite new to using which might be an option.  We also have Confluence if that might be useful to house the table.

Any help to guide me to what my options are would be greatly appreciated.

1 answer

0 votes
Mauricio Karas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2018

Hello there!

Since you have ScriptRunner, I recommend creating a scripted field to set the value of one field based on another.

Create the field in the "Script Fields" section under ScriptRunner in System > Add-ons. Then in the inline script, you can use the following code to get the components and releases:

def component = issue.components
def release = issue.fixVersions

After that, you can create some logic on top of the component and release variable to return the value you want in the "Sub-Project Number" field.

Kind regards,
Maurício Karas

Suggest an answer

Log in or Sign up to answer