Forums

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

Automation - Create comment if past specifc time of day

Ben Greene August 24, 2022

Tried a JQL statement of {{comment.created.longTime.isAfter(6:00:00 PM GMT)}}

However I get audit log errors that tell me nothing more than
'Action details:
Issue condition
The following issues passed: ticket id'

2 answers

1 accepted

2 votes
Answer accepted
bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2022

Hi,

I think the problem might lie in your smart value. "longTime" is actually a formatting function so will print the date as a String.  Once it's a string it doesn't know how to do an isAfter date comparison.  I think just removing that will get you what you need.

{{comment.created.isAfter(6:00:00 PM GMT)}}

Cheers,
Brydie

Ben Greene August 30, 2022

Hi @bmccoy 

Thanks for the response, I will give that a go and let you know if it works.

I was just now having errors with instead trying startOfDay.

Perhaps I am under the wrong impression on how startOfDay works, I looked at the documentation but I didn't see what time startOfDay refers to.

I assume it is the time of 00:00 of the current day, but maybe it instead references the beginning of a work day e.g. 09:00 ?

Ben Greene August 31, 2022

@bmccoy doesn't look to have worked sadly.

Ben Greene October 18, 2022

@bmccoy this is still an issue for us on our side, can you suggest any other methods of checking if the time is before / after a certain hour of the day?

bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 18, 2022

Hi @Ben Greene 

Sorry, I missed your previous messages and apologies for not noticing in your original example.  The problem (which looks like you've already realised) is that you need to construct a valid date object for the comparison.

{{now}} is the best way to get a starting date to convert into whatever construct you need.

{{comment.created.isAfter(now.convertToTimeZone("Australia/Sydney").toStartOfDay.withHour(18))}}

I'm also converting to my own timezone so I don't have to figure out what 6pm is in UTC time.

There is an alternative way of doing this which may or may not be nicer for your use case.  You can actually inspect the pieces of the created date instead.  e.g. 

Screen Shot 2022-10-19 at 10.07.43 am.pngHope that helps,

Brydie

bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 18, 2022

Also, as Trudy mentioned, the JQL condition is not the right condition type to be used for this type of query.   

Instead, the Advanced compare condition is the one that's designed for these more complex smart value checks.

Screen Shot 2022-10-19 at 10.15.00 am.png

Cheers,

Brydie

Ben Greene October 19, 2022

Thanks for sending that over @bmccoy !

I have updated my automation to reflect how you have done it in yours, swapping out the timezone for Europe/London.

I will let you know how it goes when I make a test comment later past 6pm.

Ben Greene October 20, 2022

@bmccoy that worked like a charm, thank you very much!

0 votes
Trudy Claspill
Community Champion
August 24, 2022

Hello @Ben Greene 

Please provide all the details of your Rule.

How are you using that JQL statement?

The log is indicating it found an issue that matches your Condition, but you didn't tell us what the condition is.

Are you expecting some action to be taken against the matching issues? What is the action? Is the action not being taken?

Ben Greene August 25, 2022

Hi @Trudy Claspill 

Thanks for the reply, yes I am expecting a comment to be made on the issue when the timeframe of the reporter's comment is outside the hours I am comparing to:

 

The comment is not being made and the error just tells me 'issue passed'

Trudy Claspill
Community Champion
August 25, 2022

Who is the Actor for the Rule? This will be shown on the Rule Details page.

Does that actor have the permissions needed in the project to add comments to the issues.

Can you show the details of the If and Else-If components?

Can you add Log Actions within your If and Else-If branches that will log a message to the audit log? That will tell you which condition specifically has been matched.

Is this the entire rule? Can you show the entire rule?

Ben Greene August 25, 2022
  1. Actor: Automation for Jira (I've made other rules that comment based on an if else using this actor, the comment appeared just fine)
  2. Yes it does
  3. The if else conditions only include the 1 condition that u can see in the pic I sent before, but will show u a full view nonetheless
  4. Sure here is the whole rule:

    When I tested this rule the reporter was not one of the ones listed, it was a business day & it was outside the hours I specified, so it isn't any of those things.
Trudy Claspill
Community Champion
August 25, 2022

In the Audit Log you should get an "Issue Conditions" message for each condition that the issue passes.

If the entirety of the Audit Log is

'Action details:
Issue condition
The following issues passed: ticket id'

...then only the first condition (Reporter is not one of) is being met by the triggering issue. The second condition (Created equals a business day) is not being met, so none of the rest of the Rule is being evaluated/executed.

I recreated your rule components, and you can see here that I get two Issue Conditions statements in my log.

Screen Shot 2022-08-25 at 10.43.52 AM.png

So, I know it is getting past those two conditions, but the Status of the rule execution is still "Some Errors". That tells me there is something wrong with the IF component that needs to be investigated.

The Log Action is very helpful to add to your rule to log messages and values into the Audit Log to help you debug the rule. For instance, you may want to add a Log Action immediately after the trigger to log the value of Created so you can see what the rule is comparing to "a business day". And I would recommend you use a Log Action to record the value of {{comment.created.logTime}} so that you can see the value being used in the comparison.

Here I've added that last Log Action I suggested.

Screen Shot 2022-08-25 at 10.48.36 AM.png

Ben Greene August 26, 2022

Didnt know about this log feature, thanks for the tip!

I've added in a couple logs to check the time and if the isAfter works, I will see what it produces when it next fails

Ben Greene September 6, 2022

@Trudy Claspill Had a go logging the longTime

 

I also tried removing the longTime argument in case that was the issue, but no dice: 

Trudy Claspill
Community Champion
September 6, 2022

@Ben Greene 

I tried a couple of things.

Based on the documentation, my first theory was that the isAfter function can't be used to compare just times. The documentation shows that it is being used to compare dates. So I tried first printing the full time stamp of the creation of a comment, and then using that text in the comparison for the next run of the run and without the longTime formatting. That still returned the "some errors" status.

Next I tried using just an explicit date in the comparison. That also returned "some errors".

Looking at the example in the documentation, then compared now to another date/time field in the issue.

{{now.isAfter(issue.created)}}

So I tried that. It still returned "some errors" but I also finally got another message in the Audit Log.

IF BLOCK
No subsequent actions were performed since JQL condition did not pass due to error running JQL:
Invalid JQL: true

That leads me to believe that this comparison can't be used in the JQL for the IF block condition.

At this point I don't know what the solution is to get what you want. If I come up with something, I'll post again.

Like Ben Greene likes this

Suggest an answer

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

Atlassian Community Events