Bad expression in post-function "Copy a parsed text to a field"
Hello, i am trying to create a workflow validator that checks if the sum of a bunch of number fields equals the entry in another number field.
I had an error there and then decided to debug this by creating a post function that writes a comment with the outcome of the formula:
(toNumber({11403}) + toNumber({11406}) + toNumber({11404}) + toNumber({11405}) + toNumber({11409}) + toNumber({11410}) + toNumber({11407}) + toNumber({11408})) + " = " + toNumber({11421})
I wrapped the fields in "toNumber" because most of them will be empty. I also tried toNumber(field1+field2+...) but that doesnt work either.
The validation i try to debug is: toNumber({11403}+{11406}+{11404}+{11405}+{11409}+{11410}+{11407}+{11408}) = toNumber({11421})
How can i make this validation work?
Thanks a lot Jens
Comments (5)
-
repo owner -
reporter - changed status to resolved
Good Morning,
that was my first try but i kept getting an error like this "null value at left hand side operand in arithmetic subtraction", i also got this error for the right hand side. But i can't reproduce this now, maybe this was just an cloning issue that was fixed by ticking the appropriate checkbox.
Thank you!
-
reporter - changed status to open
Oh i managed to reproduce it:
com.atlassian.jira.exception.CreateException: ERROR IN BOOLEAN EXPRESSION "{11403}+{11406}+{11404}+{11405}+{11409}+{11410}+{11407}+{11408} = {11421}" : Error: null value at left hand side operand in arithmetic sum operation.
I had all number fields on the left hand side empty. can i handle this case in the formula or do i have to make an separate empty check for alle the fields and run it before i run this validation (on create)
-
repo owner Hi @jkisters,
Use the following alternative expression:
sum([{11403}, {11406}, {11404}, {11405}, {11409}, {11410}, {11407}, {11408}]) = {11421}
-
repo owner - changed status to resolved
I close the issue, please reopen it if you find that provided solution is not satisfactory.
- Log in to comment
Hi @jkisters,
Field codes with with
%
(i.e., format{nnnnn}
) represent a string value, while field codes without%
represent a numeric value.We use function
toNumber()
in order to obtain a numeric value from a string. In this case you don't need to use this function, since the fields are already numeric.You should use the following boolean expression in your validation:
I'm assuming that all the fields in the formula are numeric fields.