Due Date automation clearing value instead of updating/ignoring
Asked by Erica Robinson:

I currently have an automation set up on a JSM project that reviews inbound tickets for one of these comments:

* New date to delete DB
* Upgrade has been canceled
* Upgrade has been cancelled

If individuals comment one of those three things, either the DueDate field is updated with the new value they provide or the assignee is notified that the request is canceled (two options based on spelling).

The issue I have right now is that when the due date comes through, the first time the automation runs, it works as expected and the due date is updated based on what the users comment. The second run-through it wipes out the due date and then the tickets fall off being followed up on.

On the ones that have had their due dates wiped out, I confirmed that there aren't any comments that have "New date to delete DB: ", it's just the original comment with the originally requested new due date. I'm not sure why it's wiping out the due date value.

For ease of access, here's the due date value being used:

```
{{issue.comments.last.body.substringAfterLast("DB:").toDate("MM/dd/yyyy").format("yyyy-MM-dd")}}
```

Here's the automation I have currently:

![DuedatCancelationAutomation.png](/t5/image/serverpage/image-id/344844iD79016C51C7AFB78/image-size/large?v=v2&px=999 "DuedatCancelationAutomation.png")


Answers:
author: Trudy Claspill
body: Hello [@Erica Robinson](/t5/user/viewprofilepage/user-id/5512162)

I see you have actions to add a comment to the issue noting the new due date. Are those comments getting added and do they show the correct value?

You should add validation to confirm that you successfully extracted something from the last comment. You can do that by adding a smart value Condition before your Edit action.

![Screenshot 2024-08-30 at 2.52.57?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/344887i0E63EA6CD4D9F005/image-size/large?v=v2&px=999 "Screenshot 2024-08-30 at 2.52.57?PM.png")

You have the rule running on a schedule, selecting only issues that have been updated since the last time the rule ran. And you are trying to pull the date from the "last" comment.

If a comment has been added to an issue, that will change the Updated date/time, and so the rule would select that issue. But if that last comment has nothing in it about the due date, then this rule would fail to get any information when it tried to extract such data from the comment. That would cause the Due date to be wiped out, since you don't currently have anything validating that you got a legitimate value from the last comment.

comments: author: Erica Robinson
body: Hey Trudy,

Thank you so much for the in-depth explanations and additional information.
> I see you have actions to add a comment to the issue noting the new due date. Are those comments getting added and do they show the correct value?

Unfortunately anything past the first comment did not, here's an example:

![DueDate Drop.png](https://community.atlassian.com/t5/image/serverpage/image-id/345255i11CC1AD9FBD649BE/image-dimensions/411x161?v=v2 "DueDate Drop.png")
> You should add validation to confirm that you successfully extracted something from the last comment. You can do that by adding a smart value Condition before your Edit action.

I've now added this in, thank you for pointing this piece out!
> You have the rule running on a schedule, selecting only issues that have been updated since the last time the rule ran. And you are trying to pull the date from the "last" comment.
>
> If a comment has been added to an issue, that will change the Updated date/time, and so the rule would select that issue. But if that last comment has nothing in it about the due date, then this rule would fail to get any information when it tried to extract such data from the comment. That would cause the Due date to be wiped out, since you don't currently have anything validating that you got a legitimate value from the last comment.

That makes a lot of sense with some of them where individuals emailed follow-up on top of the comment and it failed first instead of adding the due date. I'll work on providing more in-depth clarification for next steps to these teams since this is a new process for them.


Tags: automation

cloud

jira-cloud