We are trying to make Specific field to non-editable to users, somehow expression is not working properly.
I am pasting the expression below, kindly go through and suggest if any errors in these.
// Fields to be updated
const summaryField = getFieldById("customfield_10060");
//const descriptionField = getFieldById("description")
// Get the projectId out of the context
const context = await getContext();
const projectId = context.extension.project.id
// Return all project roles the current user belongs to
const getProjectRolesForCurrentUser = await makeRequest(`/rest/api/3/project/${projectId}/roledetails?currentMember=true`);
// Get the name of each project role the user belongs to
const roleNames = getProjectRolesForCurrentUser.body.map(item => item.name);
// Switch on each role and update fields if conditions met
switch (true) {
case roleNames.includes("Administrators"):
summaryField.setReadOnly(true)
// descriptionField.setReadOnly(true);
break;
default:
logger.info("No roles were matched. No actions were performed.");
}