# Calendar Component Latched red background not changing

**URL:** <https://forum.inductiveautomation.com/t/calendar-component-latched-red-background-not-changing/64288>\
**Category:** Ignition\
**Tags:** ignition79, vision\
**Created:** [September 20, 2022, 3:28pm UTC](https://forum.inductiveautomation.com/t/calendar-component-latched-red-background-not-changing/64288 "2022-09-20T15:28:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.ruel](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@michael.ruel](https://forum.inductiveautomation.com/u/michael.ruel)\
**Post date:** [September 20, 2022, 3:28pm UTC](https://forum.inductiveautomation.com/t/calendar-component-latched-red-background-not-changing/64288/1 "2022-09-20T15:28:00Z")

</div>

We have a window that is used for tracking performance data and use the calendar component as the filter for the date to run queries in the window. Recently we noticed the users rarely close the window and the latched date (red background) was still on the date the user opened the window. We decided to fix this by putting a client timer script in place to check the latched vs immediate date and if they are different to refresh the latched property. The latched property has an expression for dateformat and now(0). We tested this in Designer to make sure it works, however now that we published it does not appear to be working. We know that the script executed by a print statement in the log but the red background is still on the date the window was opened on and not now. Do we also need to have the component repaint? I would think the refresh would have forced that to happen.

---

<div class="post-metadata">

**Author:** ![michael.ruel](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@michael.ruel](https://forum.inductiveautomation.com/u/michael.ruel)\
**Post date:** [September 20, 2022, 3:31pm UTC](https://forum.inductiveautomation.com/t/calendar-component-latched-red-background-not-changing/64288/2 "2022-09-20T15:31:19Z")

</div>

```auto
windows = system.gui.getOpenedWindowNames()
#print windows
if 'Line Status/Line_Status' in windows and system.util.getInactivitySeconds()> system.tag.read("refreshLimit").value:
	window = system.gui.getWindow('Line Status/Line_Status')
	latched = window.getRootContainer().getComponent("Calendar").latchedDate
	immediate = window.getRootContainer().getComponent("Calendar").date
	#print system.util.getInactivitySeconds()
	if latched != immediate:
		cal = window.getRootContainer().getComponent("Calendar")
		system.db.refresh(cal,'latchedDate')

```

Here’s the client timer script. maybe we’re doing something wrong.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 20, 2022, 9:54pm UTC](https://forum.inductiveautomation.com/t/calendar-component-latched-red-background-not-changing/64288/3 "2022-09-20T21:54:40Z")

</div>

Just assign to it. No need to refresh the binding.

---

<div class="post-metadata">

**Author:** ![michael.ruel](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@michael.ruel](https://forum.inductiveautomation.com/u/michael.ruel)\
**Post date:** [September 21, 2022, 2:07pm UTC](https://forum.inductiveautomation.com/t/calendar-component-latched-red-background-not-changing/64288/4 "2022-09-21T14:07:19Z")

</div>

Phil,

I’m not sure I understand what you mean by “just assign to it”. There’s already an expression binding on it for “dateFormat(now(0), ‘MM-dd-yy 00:00:00’)”. We don’t want to poll this as this will cause 24 queries to execute on the poll and will change the date on the user if they are looking at historical data. The client script will check if the dates are different and the inactivity time exceeds some threshold and then refreshes the component property. I know the script executed as the print statement does show up within the latched!=immediate conditional so the property should have been refreshed, but the red box is still on the date the window was opened. Users are leaving this window open for multiple days.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 21, 2022, 2:34pm UTC](https://forum.inductiveautomation.com/t/calendar-component-latched-red-background-not-changing/64288/5 "2022-09-21T14:34:03Z")

</div>

Assigning to a bound property that **isn’t** polling yields the same result as refreshing the binding to get that result.

Consider not assigning a string. Assign a true datetime object.
