Hi all,
I started exploring the Behaviours of ScriptRunner. And I made a simple script to assign the incident ticke to myself if priority is changed to "P2 - High".
My first question is... why is the .name. have red underline? (signifying error?)
Sencond: Why is it not running when I change the priority field to "P2 - High"
Hi Zaldy:
The red underline is an error. You should not need the .name syntax at all. It should work fine if it is just getValue().toString()
Give that a try. Lastly, why you want to use ScriptRunner Behavior setup while you can just accomplish the same need via automation for Jira rule setup. The automation rule setup would be more simpler then writing out a script.
Hope this helps.
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Technology Applications Team
Viasat Inc.
Hi @Joseph Chung Yin ,
I appreciate it very much your reply on a weekend. I guess I'm not the only one working even on weekends. ;-)
The getValue().toString() got rid of the red underline. But still the Assignee did not change.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great that we resolved the redlined error. Looking at your code again, can you try to use user's account ID instead of the display name, then test it out.
Here is the example code extracted from vendor's on-line doc - https://docs.adaptavist.com/sr4jc/latest/features/behaviours/example-behaviour . As you can see it is using accountID and not the display name of the user.
const changedField = getChangeField();
const accountId = "123456-8545622-54522";
if (changedField.getName() === 'Priority') {
const priorityName = changedField.getValue().name.toString();
if (priorityName === "High") {
getFieldById("assignee").setValue(accountId);
}else{
getFieldById("assignee").setValue(null);
}
}
Hope this helps.
Best, Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Joseph Chung Yin ,
Thanks for the follow through. The link was where I got the same code. Notice that it has ".name." keyword in it?
Just so I got it right, the accountId here is the user id, correct? In this case, if I wanted it to be assigned to me, the it will be my user id of 5***701d98397639b*******.
I tried the code:
- without the ".name.", and
- adding my own user id
Unfortunately, same result as before. :-(
I even watched the youtube video of Adaptist and followed it line by line. But same result.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would recommend you to contact the vendor for further assistance - https://docs.adaptavist.com/sr4jc/latest/get-help
It is very odd that after you used AccountID it is still not working. Hopefully, it is not something that vendor has not provided the functionality to set assignee based on option selected in other field. However, they provided the example that you used from their latest documentation.
Please keep me what is their responses. I know the vendor support team is excellent in offering assistance.
Best, Joseph
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.