Forums

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

Validator for numeric field -JMWE

RIZKY JTUASIKAL
Contributor
May 28, 2023

How can I make it so that when submitting from status A to B, there is a Validator that works as follows:

 

Submit status A to B can be done, if Amount field <= 500

And, submit status from A to B cannot be done if Amount field >500

1 answer

1 accepted

2 votes
Answer accepted
David Fischer
Community Champion
May 29, 2023

Hi @RIZKY JTUASIKAL 

What is the custom field type of the Amount field? If it's a Number field, you can add a Build-your-own Validator with code like this:

!!issue.customfield_12345 && issue.customfield_12345 <= 500

where you'll need to replace customfield_12345 with the custom field id of the Amount custom field, which you'll find on the Issue Fields help tab at the bottom of the code editor. 

RIZKY JTUASIKAL
Contributor
May 29, 2023

thank you very much!!

 I learned a lot from you @David Fischer 

RIZKY JTUASIKAL
Contributor
June 5, 2023

Hi @David Fischer ,

 

sorry in advance, I wanted to ask again.

what if the condition become like this?

"Submit status A to B can be done, if Amount field <= 500 and = 0"

 

Because when I try input 0 in the Amount field, an error message will appear..

David Fischer
Community Champion
June 5, 2023

Try this:

issue.customfield_12345 != null && issue.customfield_12345 <= 500
Like RIZKY JTUASIKAL likes this
RIZKY JTUASIKAL
Contributor
June 5, 2023

thank you very much, @David Fischer !

God bless you

RIZKY JTUASIKAL
Contributor
June 7, 2023

Hi @David Fischer ,

so sorry to ask you again. :(

 

 

I have a field called Application, and its values are A, B, C

 

 

now, 

How to get the result,

if field Amount <= 500, then field Application is required but cannot select value A

(B, C can be selected)

 





is it possible to use Build-your-own validator to achieve it?

because it looks like it can't use the Field Required Validator feature

 

CMIIW

David Fischer
Community Champion
June 7, 2023

Hi @RIZKY JTUASIKAL ,

try this:

issue.customfield_12345 == null || issue.customfield_12345 > 500 || !!issue.customfield_67890 && issue.customfield_67890.value != "A"

where customfield_67890 is the field ID of the Application field (assuming it's a single-select custom field)

RIZKY JTUASIKAL
Contributor
June 12, 2023

Hi @David Fischer , sorry for the late response, because there are other things to do first.. :(

 

 

so, if the Application field is a multi-select custom field, does the query become like this?

!!issue.customfield_12213 && issue.customfield_12213.some(it => it.value != "- No Application")

David Fischer
Community Champion
June 12, 2023

Hi @RIZKY JTUASIKAL 

no, more like this:

!!issue.customfield_12213 && !issue.customfield_12213.some(it => it.value == "- No Application")

since you want to forbid the "- No Application" value.

Suggest an answer

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

Atlassian Community Events