I have this code in a scriptrunner validator:
let TotPoints = 0;
if (issue.customfield_11667 != null) {
let TotPoints = TotPoints + issue.customfield_11667;
};
But when I use it, I get this error:
Jira expression failed to parse: line 4, column 1: let, IDENTIFIER, return, throw, !, -, typeof, (, null, true, false, NUMBER, STRING, TEMPLATE_LITERAL, new, [, {, try or if expected, } encountered.
What am I doing wrong?
I am not sure what tool you are using, but the error message suggests that this is indeed a Jira expression. Then, you will need an else clause and probably return statements inside
However, assuming that TotPoints may differ, I would rewrite it to the following:
let TotPoints = 0;
issue.customfield_11667 != null ? TotPoints + issue.customfield_11667 : TotPoints
Hi @Cash Coyne
The approach you have tried will not work. When using the Jira Cloud, the Validator only allows the usage of Jira Expressions. Hence, your code fails.
I suggest referring to this ScriptRunner for Jira Cloud documentation to view the example expressions that can be used for the Validator.
Also, I suggest looking through the ScriptRunner Code snippets for examples of Validator Expression.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Cash Coyne ,
Please try like below
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aswin Raj D
The sample code you have provided is not applicable for Jira Cloud. This is meant for the Jira Server / DC Environment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try it without the trailing semicolon on the last line?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nope, get this when I drop the trailing semicolon on the last line:
Jira expression failed to parse: line 4, column 1: let, IDENTIFIER, return, throw, !, -, typeof, (, null, true, false, NUMBER, STRING, TEMPLATE_LITERAL, new, [, {, try or if expected, } encountered.
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.