Hello,
I am trying to run a ScriptRunner on load. The particular behavior is to restrict field editing to administrators only. However, it is not working. I have logged in as a simple agent and the field that I am targeting is still editable.
This is the script that I am running:
const user = await makeRequest("/rest/api/2/myself");
const { accountId } = user.body;
const getRoles = await makeRequest(`/rest/api/2/user/groups?accountId=${accountId}`);
const roleNames = getRoles.body.map(({ name }) => name);
/* Select role for priority field to be displayed... */
const role = "Administrators";
if (!roleNames.includes(role)) {
getFieldById("customfield_10174").setReadOnly(true);
}