Forums

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

setError message below a custiom field in jira scriptrunner cloud behaviour?

Leo Xie
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2025

How I could rewrite this setError function about scriptrunner behaviour in jira cloud? 

getFieldByName('xxx').setError('Error message')

2 answers

1 accepted

3 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
August 5, 2025

Hi Leo,

Unfortunately, in Jira Cloud the Behaviours module does not provide setError() function so this means your use case cannot be achieved.

The reason for this is that Behaviours in Jira Cloud uses the UI Modifications API from Atlassian, which does not provide a setError() method. 

You can see what methods the cloud version provides here for reference. The closest workaround would be to use setDescription() method to add some text to indicate an error. 

I hope this helps. 

Regards,

Kristian

 

0 votes
Howard Nedd
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 5, 2025

Hi @Leo Xie ,

In Jira Cloud, the ScriptRunner behavior API has some differences compared to the server version, particularly in how you handle field errors. 

You can use the setError method on the field object directly, but the way you access fields and set errors can vary based on the context of your script.

I have done something similar the past:

import com.onresolve.scriptrunner.canned.jira.behaviours.FieldBehaviours

def fieldName = 'xxx' // Replace with your actual field name
def errorMessage = 'Error message' // Your error message

// Get the field by name
def field = getFieldByName(fieldName)

// Check if the field is not null
if (field) {
// Set the error message on the field
field.setError(errorMessage)
} else {
// Optionally handle the case where the field is not found
log.warn("Field '${fieldName}' not found.")
}

Else. Share you script and maybe I can help.

Regards,

Howard 

 

Leo Xie
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2025

Hi @Howard Nedd the answer you provide is for jira data center, how to use setError in jira cloud? thank you

 

Howard Nedd
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 5, 2025

Hi @Leo Xie ,

You're correct that the ScriptRunner behavior API for Jira Cloud has specific nuances compared to the Data Center version. In Jira Cloud, the way to set errors on fields is slightly different, and the API is more limited.

In Cloud, you would use the setError method directly on the field object, but the context and how you access fields can differ.

Does that help?

Regards,

Howard

Leo Xie
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2025

Hi @Howard Nedd , I have tried to create behavior in jira cloud, but it remind this warning syntax message 


Property 'setError' does not exist on type 'Field<"com.atlassian.jira.plugin.system.customfieldtypes:select">'

Property 'clearError' does not exist on type 'Field<"com.atlassian.jira.plugin.system.customfieldtypes:select">'

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events