Auto Unflag on Schedule
Asked by Frank Pineiro:

Hello,   
Im very new to this automation. How can I setup automation to unflag a card in my project when the scheduled Date/Time hits? For example, the card is flagged and it has scheduled filled out for 7/5/2024 04:00, how can that card be auto unflagged?  

Thanks!


Answers:
author: Bill Sheboy
body: Hi [@Frank Pineiro](/t5/user/viewprofilepage/user-id/5553851) -- Welcome to the Atlassian Community!

You could create a rule with a Scheduled Trigger, with JQL to identify the issues, and then use the Edit Issue action to clear the Flagged field.

However...how does your team use the "flag"? That is, what does it represent?

From what you describe, automatically clearing the flag may not align to the problem the team is solving by using the flag.

To learn more about automation rules before trying to write one, please look here:

* <https://www.atlassian.com/software/jira/guides/automation/overview#what-is-automation>
* [https://www.atlassian.com/software/jira/automation-template-library#/rule-list?systemLabelId=all\&page=1\&pageSize=20\&sortKey=name\&sortOrder=ASC](https://www.atlassian.com/software/jira/automation-template-library#/rule-list?systemLabelId=all&page=1&pageSize=20&sortKey=name&sortOrder=ASC)
* <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/>

Kind regards,  
Bill

comments: author: Frank Pineiro
body: Hey Bill,

Thank you for the quick response! Under that Project, we flag cards until the scheduled date/time. I will attempt what you suggested.


author: Julia Smith
body: I was facing the same issue, but I finally resolved it thanks to your [treatment](https://sayulitawellnessretreat.com/ibogaine-retreat)of the problem.


author: Frank Pineiro
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) No dice. Pretty sure im doing something wrong.  

![Flag.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/339213i82CB76925BCC5225/image-size/large?v=v2&px=999 "Flag.jpg")


author: Bill Sheboy
body: If you mean the issue's Flagged field, isn't that the one you want to clear?

And so the scheduled trigger JQL could be:

project = "DC OPS Turnover" AND Flagged IS NOT EMPTY AND "Scheduled Date/Time" = startOfDay()

Then clear the Flagged field with the edit.


author: Frank Pineiro
body: Im attempting a search with   

project = "DC OPS Turnover" AND Flagged is not EMPTY AND "Scheduled Date/Time" = startOfDay()  

Nothing is populating. Im assuming startOfDay() is today? Once I remove "Scheduled Date/Time" = startOfDay(), I have results. I do have several items with yesterday, today and tomorrow dates.


author: Bill Sheboy
body: The function startOfDay() is a date / time value, and if your field "Scheduled Date/Time" is also date / time, they are unlikely to match exactly.

Perhaps adjust to find values within "today" with this:

```
project = "DC OPS Turnover"
 AND Flagged IS NOT EMPTY
 AND "Scheduled Date/Time" >= startOfDay()
 AND "Scheduled Date/Time" < endOfDay()
```

I recommend running that standalone first with View All Issues to confirm it returns what you wanted, and make adjustments. Then try it with the rule.


author: Frank Pineiro
body: That worked!  
When running the rule, I see a status of Success but  
the card is still flagged.  

Under Labels --\> Values to Remove  
I selected everything related to Flag.  
![Unflag.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/339429iEDC2C627FF306122/image-size/large?v=v2&px=999 "Unflag.jpg")  

Here is the test card Im using  

![Flagged.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/339432i190CEB92401E2AAE/image-size/large?v=v2&px=999 "Flagged.jpg")  


author: Bill Sheboy
body: The flag is a different field, named **Flagged**. Please use that field in the edit action, leaving the value as empty to clear it.


author: Frank Pineiro
body: Thank you Bill! All working now. Really appreciate the help!


Tags: cloud