Creating a rule to create an issue 2 business days before second business day of month.

Abhilasha Tyagi
Contributor
November 27, 2024

Hi Community,

Hoping to get some answers as always.

I am trying to create a rule that should create an issue 2 business days prior to second business day of the month. JIRA rule.png

 where I have set vartestDate to 2024-11-29 for testing.

VarmyDate is set to the smartvalue: {{vartestDate.toDate.plusmonths(1).firstBusinessDayOfMonth.plusBusinessdays(1)}}

 

varFinalDate is {{varMyDate.minusBusinessDays(2)}}

I am not able to find out y the condition is not being met. Can anyone help with the issue?

1 answer

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.
November 27, 2024

Hi @Abhilasha Tyagi 

You comparison in the condition is based on 2 variables right?

The the clause should be:

{{vartestDate}} equals {{varFinalDate}}

This as both values are stored in a variable.

Bill Sheboy
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.
November 27, 2024

Hi @Abhilasha Tyagi 

Yes, and...to Marc's suggestions:

When using rule conditions to compare dates / times, I recommend using a known and defined format, such as jiraDate: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-format---

You could add date formatting to the smart values in the condition to ensure the behavior is what you expect.

Kind regards,
Bill

Abhilasha Tyagi
Contributor
November 27, 2024

@Marc - Devoteam - I tried it but did not work. Also to have same format as of varTestdate, i tried comparing {{vartestdate}} equals{{varfinaldate.jiradate}}.

 

vartestdate = 2024-11-29

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.
November 27, 2024

Did you check that the spelling is correct, correct captals used, etc...

Abhilasha Tyagi
Contributor
November 27, 2024

Yes. I re-checked it.

 

Bill Sheboy
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.
November 27, 2024

Please post images of the condition, and your current complete rule.

 

As Marc notes, the smart values are case-sensitive, and the values you posted do not seem to match the rule's Create Variable actions in the rule image. 

The correct ones would likely be:

  • smart value condition:
    • first value: {{vartestDate.toDate.jiraDate}}
    • condition: equals
    • second value: {{varFinalDate.toDate.jiraDate}}
Abhilasha Tyagi
Contributor
December 2, 2024

This suggestion worked Bill but now the issue is that the condition is getting satisfied everyday. It should have created the subtask only on Nov 29'24 but it was success and created issues on Nov 30,Dec1 and Dec2 as well. Please find the screenshots of all variables and conditions.

 

Rule query 1.pngRule query 2.pngRule query 3.png

Bill Sheboy
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.
December 2, 2024

Smart values (including functions) are name, spacing, and case-sensitive. 

There are several errors in your Create Variable action for varmyDate and other steps, and so I suspect the rule is comparing null and null in the condition.  That could be checked with audit log writes for the variables and by reviewing the date / time documentation: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

 

Let's look at the details...

First, {{now}} is a date /time type, and thus is not followed by the function toDate.  That happens in several places in your rule.  Only when converting the variables to a date should that function be used in your rule.

 

The variable varmyDate value could be this, with corrections to the capitalizations:

{{now.plusMonths(1).firstBusinessDayOfMonth.plusBusinessDays(1).jiraDate}}

And varFinalDate could be this:

{{varmyDate.toDate.minusBusinessDays(2).jiraDate}}

 

 

I also recommend walking through scenarios like this by hand to confirm they do what you expect.  So as an example, if you ran the rule today (and it was still today in UTC)...

varmyDate = 2024-12-02 + 1 Month -> to first Business Day + 1 Business Day
= 2025-01-02 -> to first Business Day + 1 Business Day
= 2025-01-01 + 1 Business Day
= 2025-01-02

Note that Jira does not recognize 1 Jan 2025 is a holiday in some locations, and so that is the first business day of the month.  "BusinessDays (business days are considered to be Monday to Friday, 9am to 6pm)"

varFinalDate = varmyDate  - 2 Business Days
= 2025-01-02 - 2 Business Days
= 2024-12-31

Again, Jira does not recognize 31 Dec 2024 is a holiday in some locations.  If these are acceptable dates for your scenario, please disregard this information.

 

Like Marc - Devoteam likes this

Suggest an answer

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

Atlassian Community Events