how to prefill a field with pre-defined options using ScriptRunner?

24h Valiantys Support April 30, 2024

Hello,
With script runner behaviour, i want to  prefill a field compnents on jira. Is it possible?
Can i have support for writing the script please? I am new on scriptrunner please.
For example the field name is components and i want to prefilled it with example 1, example 2.
What i want to achieve is like this :
S2.PNG
But don't know what script to add:
Script.PNG
Thanks in advance

2 answers

0 votes
24h Valiantys Support May 7, 2024

Hello,
Thanks for your help but i did what you said and it seems not appearing on the component field :( It's not prefilled
lugano.PNGLugano1.PNG

Matt Parks
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.
May 7, 2024

Are you sure that the Component you are setting exists? If the Component doesn't exist for that specific project with the exact name you are providing, it won't work. The reason I ask is that you are trying to set a Component of exemple1, but maybe it should be example1?

24h Valiantys Support May 7, 2024

Yes the component exist. I mapped it to the issue type bug.
So when creating an issue type bug, I want the component field prefilled with example1 (for test)
L3.PNG
Like the case of summary
L4.PNG

Matt Parks
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.
May 8, 2024

In your script, it appears that you are trying to add a Component with a name of exemple1 into the Component/s field, but there is no Component with this name.

Unless your script is different than the screenshot you have uploaded to this post.

24h Valiantys Support May 12, 2024

Hello,
Ah i understand. Thanks for your assist.
Can you help me with the script to achieve my goal like on the screenshot please?
Thanks in advance

Matt Parks
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.
May 13, 2024

Take a look at my post from May 1st. You'll just need to update the script to reference the correct Component name.

0 votes
Matt Parks
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.
May 1, 2024

Your script is correct, but you just need to put it in the Initialiser, not the Field script.

 

2024-05-01_10-05-25.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.4
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events