Jira set a field based on another field

simon roberts March 5, 2012

Hi, i would like to set 1 filed based on other fields, is this possible? I have looked at https://studio.plugins.atlassian.com/wiki/display/JBHV/JIRA+Behaviours+Plugin#JIRABehavioursPlugin-Setonefieldbasedonanotherfieldwithinformationprovidedbytheserver

but i cant see how to do it.

Scenario:

Whilst creating an issue, user selects the severity = high, and module = UI. I would like to then default/set the value for Priority = medium.

Anyone have any tips on this?

Thanks

8 answers

1 vote
artafon March 4, 2013

Clemens, HI.

Sorry for the long waiting. I found solution for my problem. Thanks for your attention!

Warren McInnes
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 10, 2013

HI, What was the Solution? Please share

Like # people like this
balaji April 8, 2020

HI, could you please share the code,

 

I too have same scenario , will you please share the code. here

 

 

Thanks!

1 vote
Vishnukumar Vasudevan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 23, 2012

You can add a script in the description.

<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';
}
}

}

I used the above script to change the visibility of one field based on the value of another.

0 votes
Jessica Fergus June 12, 2018

Opened a new thread for this question since it is on a pretty old post.

0 votes
artafon April 20, 2013

Hi Warren!

I resolved my problem in jjupin:

//assign to the signature
string[] availableFields = {"value_1", "value_2"};
string[] t = usersInGroups("GL_Direktors");
string[] selectedCheckboxes = customfield_10607; //I want to send someone to sign
for (string field in availableFields)
{
if(elementExists(selectedCheckboxes, field)){
for(number i = 0; i < size(t); i = i + 1){
if (isUserInRole(getElement(t, i), "ID", field))
{customfield_11300 = addElement(customfield_11300, getElement(t, i));}}}
}

Warren McInnes
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 21, 2013

Thank you for your answer!

Like Lenin Raj likes this
0 votes
Warren McInnes
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 10, 2013

HI, What was the Solution? Please share

0 votes
artafon February 16, 2013

Hi Clemens!

Thank you for your attention!

And if I have some option custom field checkbox(for example, 8(10000 - 10008)) and 8 custom fields (10009 - 10017), I need to display custom fields on depending from one or more true checkbox. Could you help me, please.

CL February 21, 2013

Hi Artashes A,

Please descibe what you tried (with code example) and where you are struggling.

Like Lenin Raj likes this
0 votes
artafon February 8, 2013

Hi All.

Vishnu, could you help me for your solution in my problem.

I have custom filed multicheckbox(customfield_10000) and I would like displaying text custom filed(customfield_10001) if one of the option custom field(customfield_10000) is true - (set checkbox).

I'm not strong to correct your script, help me please. JIRA 5.2

CL February 16, 2013

I am not Vishnu :-)

However, something like this should work:

<script type="text/javascript">
multicheckbox = document.getElementById('customfield_10000');
if (multicheckbox) {
text_field = document.getElementById('customfield_10001FieldArea');
text_field.style.display='none';

multicheckbox.onchange=function() {

if (this.value) {
// Anzeige des Textfeldes, falls überhaupt Wert in Multicheckbox gewählt

text_field.style.display='';
} else {
text_field.style.display='none';
}
}

}

</script>

You can put this in the field description of custom-field 10000.

Like Lenin Raj likes this
0 votes
justindowning
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.
March 5, 2012

Like the example explains, you will need to do a few things here:

  1. Create a behaviour and indicate the field you want to monitor (severity) and specify your server-side script and method.
  2. Place the script in your classpath. You may want to query the value of both fields to make the decision to set the priority field (eg: if getFieldByName("severity").getFormValue() == "high" && getFieldByName("module").getFormValue() == "UI" )

Look at the other advanced examples for more code snippets too.

Suggest an answer

Log in or Sign up to answer