Can I use the value of one custom field to make a selection for a second custom field?

Hi there!

JIRA have the wonderful custom fields and I plan on allowing tickets to be made which the option of allocating the documentation page of the project in Confluence. So basically I want a user to select a project in JIRA using a Project Picker (or something similar) and the project they picked will be sent to the second custom field.
This second custom field will grab the documentation page with the same project name (yes we make sure they are identical) as a URL Field which gives me an URL to said page.

So is this possible? One custom field giving a value to a second custom field who then shows an URL in the issue to the documentation in Confluence.

Thanks! 

4 answers

1 accepted

While my question was about grabbing one value from another, my main goal was to make a link for JIRA to use. A JIRA Project issue is where I wanted to go but a JIRA Project itself can hold a link to the Confluence Space in its sidebar.

For people who are trying to succeed in grabbing a value from one custom field and giving it to another, I suggest you look at the answer of Doug Swartz and Amar as Scriptrunner is pretty useful in that regard.

For people like myself who purely wanted a link, you can just click "Add link"  in the sidebar from a JIRA Project and also under integrations under the cog in a Confluence Space you can add a link also.

Thank you for your answers! 

If you're running in the cloud, as indicated by the tags on the question, I don't have an answer for you. If you're running on jira-data center, you can do this by making your second custom field a calculated field in the Script Runner plugin. You should also be able to do it with the Kepler Custom Field plugin, although I've not used the Kepler plugin.

Oops! Jira-Cloud isn't the right tag. My mistake. I will try what you suggested! Thanks.

Something like a cascading select?

There is at least one add-on, but I haven't tried it.

https://marketplace.atlassian.com/plugins/com.sourcesense.jira.plugin.cascadingselect

Script runner behavior plugin is the perfect solution for your problem

https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html

https://jamieechlin.atlassian.net/wiki/display/JBHV/JIRA+Behaviours+Plugin

This is the sample code available at script runner website hope it helps

import com.atlassian.jira.component.ComponentAccessor

// set a select list value -- also same for radio buttons
def faveFruitFld = getFieldByName("Favourite Fruit") 
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(faveFruitFld.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == "Oranges" } 
faveFruitFld.setFormValue(optionToSelect.optionId)

// same example but setting a multiselect - also same for checkboxes fields
def subComponentFld = getFieldByName("Subcomponent")
customField = customFieldManager.getCustomFieldObject(subComponentFld.getFieldId())
config = customField.getRelevantConfig(getIssueContext())
options = optionsManager.getOptions(config)
def optionsToSelect = options.findAll { it.value in ["Oranges", "Lemons"] } 
subComponentFld.setFormValue(optionsToSelect*.optionId)

Hi, to be honest I really have no idea how this works. Do you perhaps have some sort of tutorial at hand? This is really quite new to me.

Hey Jackson, M also new bee, tutorial is available at https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_description Lets learn together

Lol accidently used the account of a friend when asking you about this. Thanks for your link!

Suggest an answer

Log in or Join to answer
Community showcase
Emilee Spencer
Published yesterday in Marketplace Apps

Marketplace Spotlight: DeepAffects

Hello Atlassian Community! My name is Emilee, and I’m a Product Marketing Manager for the Marketplace team. Starting with this post, I'm kicking off a monthly series of Spotlights to highlight Ma...

44 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot