# Change Script on View Param works in Preview but not in Client

**URL:** <https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753>\
**Category:** Ignition\
**Created:** [May 18, 2022, 10:09pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753 "2022-05-18T22:09:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [May 18, 2022, 10:09pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753/1 "2022-05-18T22:09:10Z")

</div>

I have a tag change script on a view param that looks like this:

**Param (end time in millis)**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b22fbae045e8726a8312a5fda0d5337c9b4a4d2f.png)

**Change Script**

```auto
	endMillis = currentValue.value
	end = system.date.fromMillis(endMillis)
	
	# make the range to the most recent hour ending
	minute = system.date.getMinute(end)
	start = None
	if minute == 0:
		start = system.date.addHours(end, -1)
	else:
		start = common.datetime.getRecentHourEnding()
	
	self.getChild("root").getChild("Input").getChild("StartTime").props.value = start
	self.getChild("root").getChild("Input").getChild("EndTime").props.value = end

```

I’m doing this because this screen is navigated to from another screen and the end value represents what hour of data to show. But then once they are on the screen, they should be able to then manipulate the start and end times manually.

This change script does exactly what I expect it to in preview mode but in a client session it doesn’t do anything.

What would make it not work in a client session?

Thanks,

Nick

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 18, 2022, 10:19pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753/2 "2022-05-18T22:19:10Z")

</div>

I think view parameters are only read once on loading the view.  
What is your change script attached to?

---

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [May 18, 2022, 10:36pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753/3 "2022-05-18T22:36:59Z")

</div>

It is on the “end” parameter

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/2/02fe050bddc00e044b0c3cd97058f9aac5dbd98a.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 18, 2022, 10:52pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753/4 "2022-05-18T22:52:13Z")

</div>

Oh, I didn’t think you could do that.

---

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [May 19, 2022, 1:08pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753/5 "2022-05-19T13:08:09Z")

</div>

I fixed this, and just to clarify, you CAN execute change scripts on view input parameters.

I had failed to see this in my logs:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/3/a3400f0c2fc6b1a126cc73fbfa3af0efed547a6b.jpeg)

So it seems there is some type interpretation error that happens when run in the client, but not in designer preview mode. This particular issue was fixed by casting the value to LONG.

```auto
	endMillis = long(currentValue.value)
	end = system.date.fromMillis(endMillis)

```

What a difference a good nights sleep makes…

Cheers,

Nick

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [May 19, 2022, 9:34pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-param-works-in-preview-but-not-in-client/59753/6 "2022-05-19T21:34:20Z")

</div>

I like to put all my perspective component scripts inside of try excepts and in the except print out the error

```auto
import traceback
system.perspective.print(traceback.format_exc())

```

Or display the info in a popup
