# Setting Window Objects from visionWindowOpened Script

**URL:** <https://forum.inductiveautomation.com/t/setting-window-objects-from-visionwindowopened-script/73503>\
**Category:** Ignition\
**Created:** [May 10, 2023, 12:30am UTC](https://forum.inductiveautomation.com/t/setting-window-objects-from-visionwindowopened-script/73503 "2023-05-10T00:30:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajrowe](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ajrowe](https://forum.inductiveautomation.com/u/ajrowe)\
**Post date:** [May 10, 2023, 12:30am UTC](https://forum.inductiveautomation.com/t/setting-window-objects-from-visionwindowopened-script/73503/1 "2023-05-10T00:30:42Z")

</div>

I'm trying to preset the start and end date ranges on a Date Range Selector using the following code. I can't get the Date Range Selector's properties to change. The code framework works from within button scripting on the page, so there's something how I'm grabbing the component from visionWindowOpened script I don't have right.

btw I also tried this way: thisWindow.getRootContainer().getComponent('Date Range 1').endDate = rightEndDate

Thanks

import time  
from java.util import Calendar, Date

thisWindow = system.gui.getWindow('Dashboards\Range Differences')

#read the Root Container's custom property: endDays  
daysToSub = thisWindow.getComponentForPath('Root Container').endDays

#calculate the end date as the day with the most recent data by stubracting daystoSub  
cal.add(Calendar.DATE, -daysToSub);  
rightEndDate = cal.getTime()  
thisWindow.getComponentForPath('Root Container.Date Range 1').endDate = rightEndDate

#calculate 7 days before the end date  
cal.add(Calendar.DATE, -7);  
rightStartDate = cal.getTime()  
#system.gui.messageBox("7 days prior: " + dateFormat.format(cal.getTime()))

thisWindow.getComponentForPath('Root Container.Date Range 1').startDate = rightStartDate

thisWindow.getComponentForPath('Root Container.Date Range 1').setRange(rightStartDate, rightEndDate)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 10, 2023, 12:35am UTC](https://forum.inductiveautomation.com/t/setting-window-objects-from-visionwindowopened-script/73503/2 "2023-05-10T00:35:12Z")

</div>

Move your script from the visionWindowOpened event handler to the internalFrameOpened event handler. If that doesn't fix it, make sure you don't have a binding on those properties that is overriding your script.

---

<div class="post-metadata">

**Author:** ![ajrowe](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ajrowe](https://forum.inductiveautomation.com/u/ajrowe)\
**Post date:** [May 10, 2023, 12:43am UTC](https://forum.inductiveautomation.com/t/setting-window-objects-from-visionwindowopened-script/73503/3 "2023-05-10T00:43:46Z")

</div>

Yep, that fixed it. Thanks so much!
