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

Rick de Jong November 11, 2015

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

0 votes
Answer accepted
Rick de Jong November 13, 2015

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! 

3 votes
Doug Swartz
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.
November 11, 2015

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.

Rick de Jong November 11, 2015

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

1 vote
A November 11, 2015

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)
Jackson Miles November 12, 2015

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.

A November 12, 2015

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

Rick de Jong November 13, 2015

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

1 vote
Sten Sundelin
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.
November 11, 2015

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

Suggest an answer

Log in or Sign up to answer