I am going through the features of ScriptRunner particularly, behavior.
I am try to hide this custom field called X
customfield_10039: {
required: false,
schema: {
type: "number",
custom: "com.atlassian.jira.plugin.system.customfieldtypes:float",
customId: 10039
},
name: "X",
key: "customfield_10039",
hasDefaultValue: false,
operations: [
"set"
]
},I used an example behaviour script
/*
* Note: You should run this script by selecting "On load" in the check box above.
* Make sure to change the priority in your script if you are affecting a different field.
*/
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("priority").setVisible(false);
}
This works fine as there is no priority field

However, if i change it to X
/*
* Note: You should run this script by selecting "On load" in the check box above.
* Make sure to change the priority in your script if you are affecting a different field.
*/
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_10039").setVisible(false);
}
It doesn't make X invisible
Why is this.
Thank you very much in advance