Set ALL fields of a screen ReadOnly dynamically

Lars Swart
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 2, 2020

Hi, 

i need a groovy script that sets all fields on a mask readonly, so I can use it for different projects and dont need to set a ReadOnly Rule for every fields manually.

 

I have the following code. When the two conditions are true, a specific field is set readonly.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def exampleField = getFieldById(getFieldChanged())

if (currentUser == underlyingIssue.reporterUser && getDestinationStepName() != "Draft")

{ exampleField.setReadOnly(true) }

else

{ exampleField.setReadOnly(false) }

 

And I have the method that gives me all the field id's

getFieldScreen().getTab(0).fieldScreenLayoutItems*.id

 

But I'm not able to write the code (beginner), that let the script iterate through all the ids and set them Readonly. 

 

I'm sure that's a simple one. 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.2.2
TAGS
AUG Leaders

Atlassian Community Events