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

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

Param (end time in millis)
image

Change Script

	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

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

It is on the “end” parameter

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

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:

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.

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

What a difference a good nights sleep makes…

Cheers,

Nick

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

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

Or display the info in a popup