Dear All,
I have created a formula which is quite complex and not easy to read. I would like to optimize the code but I am stumbling against a potential stupid syntax issue. I will post here the code. NOTE: this code is working properly but it is not so easy to read and process
...other operations are done above...
if (CONTAINS(configured_teams_Tools, summary),
WITH error_message = CONCAT(error_message; IF (summary = "SIL" and NOT(match(children_list_text ; "*CS_*")); "CS ")):
WITH error_message = CONCAT(error_message; IF (summary = "SIL" and NOT(match(children_list_text ; "*RA_*")); "RA ")):
WITH error_message = CONCAT(error_message; IF (summary = "SIL" and NOT(match(children_list_text ; "*TU_*")); "TU ")):
WITH error_message = CONCAT(error_message; IF (summary = "TERM" and NOT(match(children_list_text ; "*TEG_*")); "TEG ")):
WITH error_message = CONCAT(error_message; IF (summary = "CTF" and NOT(match(children_list_text ; "*System Definition Verifier*")); "SDV ")):
WITH error_message = CONCAT(error_message; IF (summary = "CTF" and NOT(match(children_list_text ; "*Modeling Framework*")); "MF ")):
NOT(match(children_list_text ; "*FABRIC*")); "FABRIC ")):
IF(
error_message != "", CONCAT("{panel:bgColor=#FF6666}Missing: " , error_message, "{panel}"), CONCAT("{panel:bgColor=#59B161}OK (",children_count ,"){panel}")
)
,CONTAINS(configured_teams_Core, summary),
... does similar checks as described above ...
I would like to optimize such code in a way that looks like
if (CONTAINS(configured_teams_Tools, summary),
IF (summary = "SIL")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*CS_*")); "CS ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*RA_*")); "RA ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*TU_*")); "TU ")):
IF (summary = "TERM")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*TEG_*")); "TEG ")):
IF (summary = "CTF")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*System Definition Verifier*")); "SDV ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*Modeling Framework*")); "MF ")):
IF(
error_message != "", CONCAT("{panel:bgColor=#FF6666}Missing: " , error_message, "{panel}"), CONCAT("{panel:bgColor=#59B161}OK (",children_count ,"){panel}")
)
,CONTAINS(configured_teams_Core, summary),
... does more checks as described above ...
if you have also suggestions on how to improve also the assignment to error_message, feel free to address your observation!
Thanks
A few things:
We aren't seeing everything, but I would suggest declaring error_message initially.
if (CONTAINS(configured_teams_Tools, summary),
WITH error_message = "",
IF (summary = "SIL")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*CS_*")); "CS ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*RA_*")); "RA ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*TU_*")); "TU ")):
IF (summary = "TERM")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*TEG_*")); "TEG ")):
IF (summary = "CTF")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*System Definition Verifier*")); "SDV ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*Modeling Framework*")); "MF ")):
IF(
error_message != "", CONCAT("{panel:bgColor=#FF6666}Missing: " , error_message, "{panel}"), CONCAT("{panel:bgColor=#59B161}OK (",children_count ,"){panel}")
)
,CONTAINS(configured_teams_Core, summary),
You closed the
IF(
error_message != "", CONCAT("{panel:bgColor=#FF6666}Missing: " , error_message, "{panel}"), CONCAT("{panel:bgColor=#59B161}OK (",children_count ,"){panel}")
)
So the comma on the final line
,CONTAINS(configured_teams_Core, summary),
Shouldn't be there, unless it should be part of the original if statement, but then I suggest the following change:
if (CONTAINS(configured_teams_Tools, summary),(
IF (summary = "SIL")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*CS_*")); "CS ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*RA_*")); "RA ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*TU_*")); "TU ")):
IF (summary = "TERM")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*TEG_*")); "TEG ")):
IF (summary = "CTF")
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*System Definition Verifier*")); "SDV ")):
WITH error_message = CONCAT(error_message; IF (NOT(match(children_list_text ; "*Modeling Framework*")); "MF ")):
IF(
error_message != "", CONCAT("{panel:bgColor=#FF6666}Missing: " , error_message, "{panel}"), CONCAT("{panel:bgColor=#59B161}OK (",children_count ,"){panel}")
)
)
,CONTAINS(configured_teams_Core, summary),
Just wrapped the middle expression in parenthesis.
And you have already checked for
CONTAINS(configured_teams_Core, summary)
So you can probably remove the second check if it is to be part of the original if statement.
Let me know if this helps.
Not really an answer, so not sure if this will help :-)
I had a similar problem where nested IF statements caused a syntax error.
I ended up running my code through Copilot (Microsoft AI) requesting to rewrite formula to resolve the syntax errors. In a few steps and with some corrections, it did help me get a clean and functional formula.
Here's what Copilot had to say:
"Jira expressions do not support traditional nested IF
statements like you might find in Excel or programming languages like JavaScript. Instead, Jira expressions use conditional (ternary) operators for branching logic.
Jira expressions can get tricky when multiple conditions are involved, but you can always break them down into separate variables for better readability"
You could also ass comments at every step to make it easier to understand.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.