Forums

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

Custom field text based on other custom field values

John_Smith
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 24, 2020

Hello, I'd like to create a JIRA ticket field where its value is based on the value of two other custom fields.

 

For instance, the values could be:

Custom field 1: coffee
Custom field 2: cup

 

I would then end up with the following being displayed:

Custom field 3: coffee_cup

 

Custom field 3 doesn't necessarily have to be editable. I'm using JIRA Server 8.5. Any help would be much appreciated!

 

John

2 answers

0 votes
Andrew Laden
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.
April 24, 2020

You can also do this with a Power Scripts custom field.

https://marketplace.atlassian.com/apps/1210749/power-custom-fields-for-jira?hosting=server&tab=overview

Could do it in 1 line. 

return customfield_10000 + " _" + customfield_10001;

John_Smith
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 24, 2020

Any options that don't utilize a plug-in? I have a feeling my organisation may not permit third-party apps...

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.
April 25, 2020

No, you'll need a plugin.  You'll find Scriptrunner can do it in one line of code too, and soon, without any code at all.  And Autoblocks.

0 votes
Moses Thomas
Community Champion
April 24, 2020

@John_Smith 

  • If you have the Script runner  plugin you can do it with the script below by  adding a post function script  on the create transition in the Work flow.
  • Now to get the custom field object, press F12 then click on inspect in the Firefox developer view, drag the cursor to the field on create screen, later you can remove it to make sense and then you will see "customfield_id"  You can also get the by going to custom field on the JIRA admin panel and edit the field then you will see the id, so you will now have "customfield_id"
  • After that just put the customfield3 on the view screen that you want to set base on customfield1 and customfield2 on the create screen

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

CustomField cf86900 = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_86900")
String cf86900Value = issue.getCustomFieldValue(cf86900)

CustomField cf87301 = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_87301")
String cf87301Value = issue.getCustomFieldValue(cf87301)

CustomField cf87001 =ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_87001")

issue.setCustomFieldValue(cf87001, cf86900Value + " " + cf87301Value)

 

Kind regards,
Mo

Suggest an answer

Log in or Sign up to answer