You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
I have field1 and fieild2 on my issue ticket.
I try to use the script runner to do a simple action that raises an error when the user edit field1 with value that higher then field2 with the next code:
if (getActionName() == null){ //check that we are on edit screen
def field1 = getFieldByName("Paid Assets/Apps")
def fieild2 = getFieldByName("Planned Assets/Apps")
if (field1.getValue() < fieild2.getValue())
{
fieild2.setError("fieild1 can not be lower than fieild2")
}
else {
fieild2.clearError()
}
}
Seems it works and the error raising - SOMETIMES.
When field1 = 100 field2 = 10 everything OK, but
when field1 = 100 field2 = 20 (or each another number without any consistent) the ERROR raised without any reason (field1 > field2 as it should)
I get crazy from that unexplained BUG.
Hope for help ! :)
Hello,
What are the field types?
You can add logging to see the class of the returned values. Maybe it returns String or something like this:
if (getActionName() == null){ //check that we are on edit screen
def field1 = getFieldByName("Paid Assets/Apps")
def fieild2 = getFieldByName("Planned Assets/Apps")
log.error("field1.getValue(): ${field1.getValue().getClass()}")
log.error("field2.getValue(): ${field2.getValue().getClass()}")
if (field1.getValue() < fieild2.getValue())
{
fieild2.setError("fieild1 can not be lower than fieild2")
}
else {
fieild2.clearError()
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You were right, the value that I get from those are 'String'
Thank you !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.