How can I use {{smart values}} condition?
Asked by Dailet:

I'm in the process of setting up an automation rule that will be triggered when a comment is the primary action. To give a clearer picture, I aim to create an automation that will, upon the creation of a comment, consider the author of the comment, the status of the issue, a specific text within the comment, and the date when the comment was created (emphasizing the creation date as opposed to updates). Following these criteria, I intend to assign a user and modify other fields in the issue.

Here's an example scenario: If a comment is created between "2024-06-10T00:00:00" and "2024-06-15T00:00:00", is authored by User1, contains the phrase "migrate it", and the issue's status is In Progress, then I want to assign that issue to UserX.

When selecting the condition type, I noticed the option to use "{{smart values}} conditions. The benefit of using smart values is that I can access:

- {{triggerIssue.comments.created}}

- {{triggerIssue.comments.body}}

- {{triggerIssue.comments.author.displayName}}

- {{triggerIssue.status.name}}

![2024-06-13_103949.jpg](/t5/image/serverpage/image-id/329712i9BE89EF75516C810/image-size/large?v=v2&px=999 "2024-06-13_103949.jpg")![2024-06-13_102858.jpg](/t5/image/serverpage/image-id/329713iB55EFA187F00360F/image-size/large?v=v2&px=999 "2024-06-13_102858.jpg")

I have tried various options for the values in the first and second positions, but my query is still not working bc the conditions are not matched.


Answers:
author: Duc Thang TRAN
body: Hello [@Dailet](/t5/user/viewprofilepage/user-id/5520283)

Do your ticket have more than 1 comment ?   
If is the case, can you try with {{issue.comments.last.body}} {{issue.comments.last.author.displayName}} etccc ?

and for date

{{triggerIssue.comment.last.created.format("dd/MM/yyyy")}}

![2024-06-13 16_59_37-Audit log - Automation - Scrum03 - Jira.png](https://community.atlassian.com/t5/image/serverpage/image-id/329720i29D2C5A2ED9A80BC/image-size/large?v=v2&px=999 "2024-06-13 16_59_37-Audit log - Automation - Scrum03 - Jira.png")

comments: author: Dailet
body: ok, let me try that


author: Dailet
body: I udpated my smart values condition for {{triggerIssue.comment}} to  

{{triggerIssue.comments.created.format("dd/MM/yyyy")}} for both conditions, greater than and les than and it worked!

![2024-06-13_111836.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/329728i6F6035520A5C7D36/image-size/large?v=v2&px=999 "2024-06-13_111836.jpg")

<br />

but I'm still struggling with the smart values conditions that I'm comparing against strings, like {{issue.comments.last.body}}, {{issue.comments.last.author.displayName}} and {{triggerIssue.status.name}}

Any recommendation with those?  

I changed them to {{issue.comments.last.author.displayName.equals("User1")}} equals true but that didn't work  

![2024-06-13_112309.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/329730i36B3785E6C165553/image-size/large?v=v2&px=999 "2024-06-13_112309.jpg")  


author: Duc Thang TRAN
body: [@Dailet](/t5/user/viewprofilepage/user-id/5520283) Hum , can you make something like my screen, it work for me

![2024-06-13 17_50_53-Window.png](https://community.atlassian.com/t5/image/serverpage/image-id/329756i53FCB79EEE7C1B09/image-size/large?v=v2&px=999 "2024-06-13 17_50_53-Window.png")


author: Dailet
body: mmm... I should remove the double quotations "" then... ok, I'll try


author: Dailet
body: it worked!!! Thanks [@Duc Thang TRAN](/t5/user/viewprofilepage/user-id/5371199)


author: Dick
body: Hi Dailet, welcome.   
The stuff in quotes is a string, the smart values in your comparison are dates.  
you must compare apples to apples, otherwise both comparisons give a "false" result, which means the rest of the code is not executed.   

You would need to convert the string to a date(-object)

More on entering your own dates and convert those to Automation dates is written in [Converting string to date object with Automation](https://community.atlassian.com/t5/Jira-questions/Converting-string-to-date-object-with-Automation/qaq-p/1150977)

or vice versa:

More on this can be found on the [Atlassian smart values page on date and time](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/)

comments: author: Dailet
body: Ok... this means that if I want to trigger an action only if the comment was created after june 10th, 2024 then I must convert "2024-06-10" into a jiraDate?  

Like this {{2024-06-10.jiraDate}}?


author: Dick
body: best convert the object to a string with a suitable format which you choose, then match the date-string you want to compare it with in similar format.


author: Dick
body: you can define your string in a variable Automation object:  
{{comparisondate}} = "2024-04-10"

(the code for entering april 10th \^\^)

then convert it to a real date object with the {{comparisondate.format("yyyy-MM-dd")}} command.


Tags: automation

cloud

condition

jira-cloud

smart-value