Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello!
I'm trying to use ScriptRunner Behaviours to make a field read-only once it's filled out. I can get this to work for certain field types (i.e., single-select) but not for numeric field types. Any ideas how to access the "value" for a numeric field type or is it not possible? TYIA!
var storyPoint = getFieldById("customfield_XXXXX")
var storyPointValue = storyPoint.getValue()
if(storyPointValue != null){
storyPoint.setReadOnly(true);
}
else {
storyPoint.setReadOnly(false);}
"customfield_10255": { "self": "https://< >.atlassian.net/rest/api/2/customFieldOption/10424", "value": "Yes", "id": "10424" },
"customfield_10025": 5,
Hi @Brandon Moberg ,
Unfortunately, Behaviours on Jira Cloud does not currently support the Numeric Custom Field Type. As the underlying API we use for Behaviours is still being developed by Atlassian, there are a number of fields types that Atlassian have not yet built support for, so we cannot include them in our Behaviours feature.
You can find a full list of what fields are supported, and what actions on those fields are supported in our documentation here.
You can also leave us feedback on what features you would like to see next in Behaviours on our Nolt Board here. Whilst we don't decide what Atlassian will work on next, we can take the feedback we get from customers to let them know what you are looking for!
Sorry I wasn't able to give you a more helpful answer.
Kind regards,
Bobby
Hi Brandon,
As Bobby mentioned, number fields are not yet supported.
The only workaround is to call the .toString() method to return the value as a string and set this in a text custom field.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there,
Thank you for the replies, I appreciate it. @Kristian Walker _Adaptavist_ do you have an example of the workaround you mention?
When I add .toSring() method to my value I'm returning an [object object] string. How do I return the appropriate value (i.e., 5)? From there, I track the suggestion to set this value in a separate field and make that field required to mimic the desired functionality.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Brandon,
I can confirm the object object error being returned means the value is an Object, and you need to extract the value out of the object to be able to set this as a String.
I have created the example, which you can view here, and this shows how to get the value out of a single Select List field and set it in a text field on the Create Screen using Behaviours in Jira Cloud.
You can use this example as a guide to help achieve your requirements.
It will not be possible to get a number field value as Bobby mentioned, as you can only set values to a text field which is returned from fields which Behaviours supports.
I hope this answer helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.