Scriptrunner Behaviors Cloud - Set a default value for Component on the Create Screen

Anthony Giordimaina November 7, 2024

I'm looking to use Scriptrunner Behaviors in Cloud to set the Component of an issue to a default value on Load on the Create screen.

The solutions I've seen for default values are either for strings (component not being able to be set by a string) or for setting after creation (we want to pre-fill on the Create screen).

Any guidance on how to accomplish this would be greatly appreciated.

Thanks!

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
2 votes
Answer accepted
Bobby Bailey
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.
November 7, 2024

Hi @Anthony Giordimaina , 

To do this all you would need to do is create a Behaviour for the project and issue types you want to cover, and then in script select "On load" and "Create View". Then the code would be:

getFieldById("components").setValue(["COMPONENTID","COMPONENTID"])   

 

So will look like this: 

 

Community Screenshots2.png

 

You can read more on how to get/set every field type we support, as well as all the other methods available to you here: https://docs.adaptavist.com/sr4jc/latest/features/behaviours/behaviours-api

If you can't find your component ids (took me a little bit) you can enter this into your browser and it will output all your components with their IDS:

https://{DOMAIN}.atlassian.net/rest/api/2/project/{PROJECTKEYORID}/components

 

Let me know if this works for you!

Kind regards,

Bobby

Anthony Giordimaina November 7, 2024

This works exactly how I wanted. Thanks Bobby.

Like Bobby Bailey likes this
mahboob_sharif
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 7, 2024

the linked document is very helpful

Like Bobby Bailey likes this
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events