Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner update a field

Eran Roiter
Contributor
June 26, 2024

In order for ScriptRunner in Jira to update a field is it necessary that the custom field will be Associated in an edit screen or is it enough to have in in View screen?

 

When a field is only on a view screen, it won't appear in the issue type, even though it is shown in the configuration of this issue type. As long as the field is on the view screen only, the script will fail. However, once I add it to the edit screen, it works.

The problem is, I don't want this field to be editable.

Any ideas on what I should do?

1 answer

1 vote
Melo
Community Champion
June 26, 2024

Hi @Eran Roiter

Have you tried leaving the field in the edit screen but using behaviors to make it read-only? The script should be something like this:

const customField = getFieldById("customfield_00000");

customField.setReadOnly(true);

Just replace "customfield_00000" with the actual custom field ID.

 

According to the ScriptRunner assistant, "The field will still be editable by other scripts. Setting setReadOnly(true) only affects the user interface, making the field appear read-only to users. Scripts can still modify the field value using setValue."

I hope it helps.

Cheers,

Melo

Suggest an answer

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

Atlassian Community Events