Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem hiding a specific customfield in scriptrunner

Fawaz Joseph October 23, 2023

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

image.png

 

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
image.png
Why is this.
Thank you very much in advance

1 answer

1 accepted

2 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
October 24, 2023

Hi Joseph,

Thank you for your question.

I can confirm that inside ScriptRunner for Jira Cloud, number fields with the key of 

"com.atlassian.jira.plugin.system.customfieldtypes:float"

like you are using are not supported by Behaviours, which is why you cannot hide this field.

You can see the field types which are supported by Behaviours inside of the documentation page located here.

Also, if you have a use case to support Number fields, can you please raise it here so that our product manager can see this and review it.

I hope this information helps.

Regards,

Kristian

Fawaz Joseph October 24, 2023

Thank you Kristian.
I didn't even know that all custom fields type weren't supported.

 

Thank you

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events