Set Priority from Behaviour in JIRA 5.1

I am trying to set the Priority field to a specific value via a Behaviour. This is my code:

import com.atlassian.jira.issue.IssueFieldConstants

import java.util.List

FormField formPriority = getFieldById(IssueFieldConstants.PRIORITY)

List<String> myList = new ArrayList<String>();

myList[0] = "5"


There is no error in the script, but it does not set the value.

Logs show:

/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.groovy.BehaviourManagerImpl] Returning map: [priority:[setValue:[5], fieldType:com.atlassian.jira.issue.fields.PrioritySystemField, displayName:Priority]]

Anybody knows what is wrong with this script? Does the setFormValue for Priority field take string/list/object?


1 answer

I guess you will need to pass the value of the priority as argument

If we observe the HTML

&lt;option class="imagebacked" data-icon="/images/icons/priority_minor.gif" value="4"&gt; Minor &lt;/option&gt;

value is 4 so ,


Will set the priority as minor

Hope this helps

Add logging to your code . I also see that you are passing the whole list which is not correct , try passing myList[0] as an argument

Thanks Mizan. formPriority.setFormValue("4") worked.

The stange thing is when the behaviour executes on my create issue page, shouldnt the priority field value change there? I can see the behaviour script has executed, but the create page shows the default value only. When I submit the page, I can see the issue is created with my updated priority value.

Try getFieldById("priority") .

The field should change to the value your are setting to on the create screen as well , have you put any conditions ? what else your script does ?

Yes I tried with getFieldById("priority") as well. After submitting the page the priority changes to the one I want. But the the Priority value in the drop down does not change when I am on the Create page.

I tried putting in a sample Description value, and that comes up properly.

On what field have you added that server-side script?

I have added it on the Summary field change.

Since Summary is the first field on my Create page, change in the Summary field will trigger an update on the Priority field.

You will need to add the groovy script as a server side script in the priority field . So as soon as the page is loaded the priority will be set according to your script . It will get triggered automatically .

Just to confirm you are adding this script in the text area provided by the behaviours plugin , right ?


Yes, I tried adding for the Priority field as well. The behaviour executes, but the Create page still shows the system default priority.

import com.atlassian.jira.issue.IssueFieldConstants
import java.util.List

FormField formPriority = getFieldById("priority") 
List&lt;String&gt; myList = new ArrayList&lt;String&gt;()
myList[0] = "5"

Only after submitting it, can I see the priority set properly on the View page.

The reason I added the behavior on the Summary field was, the user should be able to change the priority if he wants. If I add the behaviuor on the Priority field itself, it will not allow changes to it.

And Yes, the script is in the text area of the Behaviour plugin.

Mizan, Jamie,

Let me know if you have seen this issue earlier.

I have not seen such issue earlier .

If I add the behaviuor on the Priority field itself, it will not allow changes to it.

This is not correct the user can change the priority later . Your script will execute only once the page is loaded .

I tried the script at my end and observed that the option is disappearing when the script run .


"the option is disappearing when the script run"

I did not understand this. Can you provide the script you used?

I am using JIRA 5.1.8.

I used the same script same JIRA version , This is probably a bug with Behaviours plugin . You can raise it here

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,088 views 4 9
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