Example scripts
To homepage
Jira

Make Fields Editable to only users in a certain role
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira
Language |
typescript
// Fields to be updated
const summaryField = getFieldById("summary");
const descriptionField = getFieldById("description")
// Get the spaceId out of the context
const context = await getContext();
const spaceId = context.extension.project.id
// Return all space roles the current user belongs to
const getSpaceRolesForCurrentUser = await makeRequest(`/rest/api/3/project/${ spaceId }/roledetails?currentMember=true`);
// Get the name of each space role the user belongs to
const roleNames = getSpaceRolesForCurrentUser.body.map(item => item.name);
// Switch on each role and update fields if conditions met
switch (true) {
case roleNames.includes("Developers"):
summaryField.setName("Ticket Summary");
descriptionField.setName("Ticket Description");
break;
case roleNames.includes("Administrators"):
summaryField.setReadOnly(true)
descriptionField.setReadOnly(true);
break;
default:
logger.info("No roles were matched. No actions were performed.");
}Having an issue with this script?
Report it here