Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Problem hiding a specific customfield in scriptrunner

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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 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

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
Site Admin
TAGS
AUG Leaders

Atlassian Community Events