Forums

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

how to use formField.setError with a customfield in script runner

Nannette Mori
Contributor
January 25, 2023

In my script I wanted to use formField.setError but when using formField.setError where do you define the customfield you want the error to set to?

1 answer

0 votes
Florian Bonniec
Community Champion
January 25, 2023

Hi @Nannette Mori 

 

First this function apply to Behaviour script only.

 formField.setError means that you have define formField before with something like

formField = getFieldById("customfield_11111")

 

https://docs.adaptavist.com/sr4js/latest/features/behaviours/api-quick-reference

 

Regards

Nannette Mori
Contributor
January 25, 2023

If I use formField = getFieldbyId("customfield_1111")

I get formField variable is not defined.

Florian Bonniec
Community Champion
January 25, 2023

Yes it's was just an example, you have to adapt using the field id of the field you want to set the error under.

Nannette Mori
Contributor
January 25, 2023

Yes I realize that - but when I used formField = getFieldById with my customfield I got the formfield is not a variable.

 

I am trying to use formfield with a date field

Florian Bonniec
Community Champion
January 26, 2023

Are you in the Behaviour section of Scriptrunner ?

 

You need to define if so it will be something like that

 

def formField = getFieldById(....)

Nannette Mori
Contributor
January 26, 2023

yes

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.22.6
TAGS
AUG Leaders

Atlassian Community Events