How to write an automation to autoclose new issue when 2 fields match?
Asked by Bridget Caci:

Hello,

I am trying to build an automation to automatically transition a new issue to Canceled status if the Target Date field value equals the issue create date. I use Jira Service Management Data Center.

I can get the automation to work for all created tickets or none at all, but not for the conditions I need.

Here is my current version:

When: Value changes for Target Date

If: Customer Request Type equals Branch Rate Match Request

And: Compare two values: Checks if {{issue.customfield_13901-val}} equals {{issue.Created-val}}

Then: Transition the issue to Canceled

This version works for tickets when the Target Date = Created Date **and** when it does not equal. For my test issue, I entered 4/1/2024 in the Target Date field, with the Created date as 4/10/2024. The Audit Log says this matched the Condition: Compare two values.

Can you advise on how I can set this automation so that it only auto-transitions when the fields truly match?

Thanks!


Answers:
author: Bridget Caci
body: Here is a screenshot of my rule and audit log.

![Screenshot of Automation and Audit Log.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/317481iDB608BF5C5FD1EC4/image-size/large?v=v2&px=999 "Screenshot of Automation and Audit Log.jpg")

comments: author: John Funk
body: Take off the -val on the two fields.


author: Bridget Caci
body: I removed the -val and created a test issue, with Target Date: 4/10/2024 and Create Date: today (4/10/2024). But the status did not auto transition.

![Screenshot of Automation and Audit Log2.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/317499iED578335A80F42FD/image-size/large?v=v2&px=999 "Screenshot of Automation and Audit Log2.jpg")


author: John Funk
body: It's probably including the time. Maybe try .jiraDate on the end of each date field.

{{issue.created.jiraDate}} for example.


author: Bridget Caci
body: Sorry, John. Another strike out. I completed the same test - new issue with Target Date and Create date as 4/10/2024.

![Screenshot of Automation and Audit Log3.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/317501iF01365D561910973/image-size/large?v=v2&px=999 "Screenshot of Automation and Audit Log3.jpg")


author: Kalyan Sattaluri
body: Hello [@Bridget Caci](/t5/user/viewprofilepage/user-id/5310471)

Please insert a log statement before your compare and log both values and share the audit log.

{{issue.customfield_13901.jiraDate}} equals {{issue.Created.jiraDate}}


author: John Funk
body: Looks like there is a typo in your code. Try to page in Kaylan's example. Also you might need to put Created as created (lowercase) as it is case sensitive sometimes.


author: Bridget Caci
body: I haven't inserted a log statement before, so please let me know if I need to make changes. As I have it written, it did not auto transition when I tested.

![Screenshot of Automation and Audit Log4.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/317504i2A8D9621098F84E3/image-size/large?v=v2&px=999 "Screenshot of Automation and Audit Log4.jpg")


author: Bridget Caci
body: For reference, here is a screenshot of Auto-985.

![screenshot of test ticket.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/317507iECC6A2958CB7B401/image-size/large?v=v2&px=999 "screenshot of test ticket.jpg")


author: Kalyan Sattaluri
body: Hello [@Bridget Caci](/t5/user/viewprofilepage/user-id/5310471)

As [@John Funk](/t5/user/viewprofilepage/user-id/7148) has mentioned, you have a typo in your compare of If condition :p

Please revise it to:

{{issue.customfield_13901.jiraDate}}

And you did great with the log. Always log values so you know what values they hold.

Hope it helps and accept answer so it benefits others in the future. Thanks!!


author: Bridget Caci
body: This is perfect! This is exactly what we needed - adding the log statement and fixing the typo. We ran several tests and it worked properly each time.

Thank you all so so much for your help!


author: John Funk
body: Great! Glad it worked out.


author: John Funk
body: Hi Bridget,

Can you share the actual rule? That will help us to troubleshoot it.

And also the details of the audit log when it runs.

comments: author: YY Brother
body: Hi John,

It seems the two dates comparing is not correct:

And: Compare two values: Checks if {{issue.customfield_13901-val}} equals {{issue.Created-val}}

Thanks,

YY?


author: YY Brother
body: Hi [@Bridget Caci](/t5/user/viewprofilepage/user-id/5310471)

Welcome to our community. Please try it and refer to this link for more details:

<https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/>

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/317480iAFA4AA6EF2974039/image-size/large?v=v2&px=999 "image.png")

Hope it helps. Thanks,

YY?


Tags: data-center

jira-service-management

jira-service-management-data-center