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"
formPriority.setFormValue(myList)
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?
-Rahul
I guess you will need to pass the value of the priority as argument
If we observe the HTML
<option class="imagebacked" data-icon="/images/icons/priority_minor.gif" value="4"> Minor </option>
value is 4 so ,
formPriority.setFormValue("4")
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On what field have you added that server-side script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mizan,
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<String> myList = new ArrayList<String>() myList[0] = "5" formPriority.setFormValue(myList[0])
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mizan,
"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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I used the same script same JIRA version , This is probably a bug with Behaviours plugin . You can raise it here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.