Forums

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

I have a formula in Structure with several nested IF-ELSE but I am facing a syntax error

Alessandro Marinelli April 29, 2025

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

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Kiam Venter
Contributor
May 1, 2025

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.

0 votes
Bert Dombrecht
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 29, 2025

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.

TAGS
AUG Leaders

Atlassian Community Events