Forums

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

Rule builder code syntax not working, what am i doing wrong?

MarcelMeeuwissen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 3, 2024

Hey guys,

We are currently implementing an ISO 27001:2022 ISMS in JIRA + Confluence. We only have one issue left that has to do with automation in JIRA, but for the love of me i can't figure out how to fix it. I've looked at the documentation and asked chatgpt but i cannot find the answer. Maybe someone here can?

I have two custom fields in my ISO 27001 issues, one is named "Due Date (ISO)" and the other is named "Check Frequency (ISO)". If an issue that has both these values filled in gets closed or resolved, i want a new issue cloned and the "Due Date (ISO)" set to a new date (e.g. a month, quarter, year, etc later). 

So for example, Due Date (ISO) is 31/12/2024. Check Frequency (ISO) is 'Yearly'. I want the cloned issue to be the same issue but the Due Date (ISO) should be set to 31/12/2025.

The conditions (fields not empty) work and the automation clones the issue just fine, but the Due Date (ISO) is emptied. What am i doing wrong?

You can find the screenshot and then the code underneath the screenshot. In the 'fields to set' pulldown, only "Due Date (ISO)" is selected.

Thanks in advance!

 

Screenshot 2024-09-03 at 11.15.10.png

 

 

{{if(equals(issue.Check Frequency (ISO), "Monthly"), issue.Due Date (ISO).plusMonths(1), if(equals(issue.Check Frequency (ISO), "Quarterly"), issue.Due Date (ISO).plusMonths(3), if(equals(issue.Check Frequency (ISO), "Yearly"), issue.Due Date (ISO).plusMonths(12), if(equals(issue.Check Frequency (ISO), "Two-yearly"), issue.Due Date (ISO).plusMonths(24), if(equals(issue.Check Frequency (ISO), "Three-yearly"), issue.Due Date (ISO).plusMonths(36))))))}}

 

2 answers

0 votes
Marc - Devoteam
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.
September 3, 2024

Hi @MarcelMeeuwissen 

A field value set on using smart values can only contain a value, based on the smart value.

You can't use IF/ELSE statements in setting a field value.

That's where you need the IF/ELSE condition in the rule

0 votes
Jovin
Community Champion
September 3, 2024

Hey @MarcelMeeuwissen 

I would suggest breaking this out into the Automation Actions for "IF/ELSE", it makes it much easier to read and maintain.

This IF/ELSE assumes you've already created the issue, and is now modifying the due dates accordingly.

  • IF Issue field value
    • Field: Check Frequency (ISO)
    • Condition: Equals
    • Value: Monthly
    • THEN: Action: Edit Issue
      • Field: Due Date (ISO)
      • Value: {{issue.Due Date (ISO).plusMonths(1)}}
  • ELSE Issue field value
    • Value: Quarterly
    • THEN: Action Edit Issue
      • Value: {{issue.Due Date (ISO).plusMonths(3)}}
  • etc. etc.
MarcelMeeuwissen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 3, 2024

Hi Jovin, not to sound ungrateful but this was exactly what i was trying when you replied to my post - so i'm happy to hear you confirm this is a better idea. Thank you for your efforts. Sadly i did wish to understand why the code doesn't work, but there are just not enough resources on this to understand it, i guess. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events