Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ScriptRunner Behaviours not working?

Zaldy Parian
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.
October 27, 2023

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"

scriptrunner.png

 

1 answer

0 votes
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 27, 2023

@Zaldy Parian -

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.

Zaldy Parian
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.
October 27, 2023

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.

behaviour.gif

Regards,

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2023

@Zaldy Parian -

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

Zaldy Parian
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.
October 29, 2023

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.

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2023

@Zaldy Parian -

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events