session.props.auth.user.userName

I have a onStartup script on a table, it calls a script that it passes self to, this comes back with NoneType:

caller.session.props.auth.user.userName

After the view loads I have a refresh button that does the same thing but it works fine. Any thoughts?Thx, jake

Startup is before login or even a solid session ID. You’ll need to pick a different event.

What would be an event after the session starts and before the view loads?

Anybody else know a better event to do this?Thx, jake

I’ve tried using messages but it seems the view and session aren’t ready to roll at the same time. The only thing I need from the session is the username, is there another way to get this?Thx, Jake

Without your specific requirements it is difficult to make suggestions :slight_smile: . Why do you need the username on table startup? Is it to load data based on the user logged in?

If this is the case, why not reference the session.props.auth.user.userName in the data binding?

If this is not the case, please post more information, images, etc.

So after login the user is brought to a view with a table that lists things based on the login. The script fills out the list and uses self to get the session props and 2 controls to fill out the list properly. There’s a refresh button that works fine, would like the table filled out when the user logs in so they don’t have to hit refresh. Many people now think the scada is broken, 7.8.5 could do this so they are coming from that and think 8.1.x is broken.
The list can’t build itself because it’s far too variable.Thx, jake

@codersmurf, where is the data for the list coming from, is it from a DB?

Can you post screenshots of the script?

def Load(caller):
units_tag = caller.session.props.auth.user.userName
hide_customer = False;
if units_tag == ‘Demo’:
hide_customer = True

units = system.tag.readBlocking(['[default]' + units_tag])[0].value.split(',')

unitList = caller.getSibling("Units")
filter = caller.getSibling("Filter")
ds = []

for unit in units:
	filterv = system.tag.readBlocking(['[default]' + unit + '/Territory'])[0].value
	if filter.props.value != 'All' and filter.props.value != filterv:
		continue
	statusv = system.tag.readBlocking(['[default]' + unit + '/Status'])[0]
	color = GetColor(statusv.value, statusv.quality.isGood(), unit)
	status = ""
	company = ""
	location = ""
	volts = ""
	d = system.tag.readBlocking(['[default]' + unit + '.enabled'])[0].value
	if d == False:
		comploc = system.tag.readBlocking(['[default]Disabled-' + unit])[0].value.split(',')
		status = "NA"
		if hide_customer == True:
			company = "NA"
			location = "NA"
		else:
			company = comploc[0]
			location = comploc[1]
		volts = "NA"
	else:
		if hide_customer == True:
			company = 'NA'
			location = 'NA'
		else:
			company = system.tag.readBlocking(['[default]' + unit + '/Company'])[0].value
			location = system.tag.readBlocking(['[default]' + unit + '/Location'])[0].value
		if statusv and statusv.quality.isGood() == True:
			statusi = system.tag.readBlocking(['[default]' + unit + '/StatusIndicator'])[0]
			status = Faults.GetLabel(statusi.value, statusv.value)
		else:
			status = "NA"
		compv = system.tag.readBlocking(['[default]' + unit + '/CompMainsVoltage'])[0]
		if compv and compv.quality.isGood() == True:
			volts = "%4.1f" % compv.value
		else:
			volts = "NA"
	data = {"Unit": {"style": {"classes": color}, "value": unit}
			,"Company": {"style": {"classes": color}, "value": company}
			,"Status": {"style": {"classes": color}, "value": status}
			,"Location": {"style": {"classes": color}, "value": location}
			,"CVDC": {"style": {"classes": color}, "value": volts}}
	ds.append(data)

unitList.props.data = ds

@codersmurf, could this be moved to a binding on props.data that uses a property binding linked to the session.props.auth.userName and a script transform with the above script?

The advantage of this is that the binding ‘should’ evaluate after the table loads. Also, if the userName changes it will refresh the binding. The refersh button can also simply be updated to use [pathToTable].refreshBinding(‘props.data’).

Apologies if I’m heading down the wrong path or interpreted anything incorrectly.

From what I’ve read and been told it’s far too complicated for bindings.

Anybody else have any thoughts? I’ve updated to 8.1.3 with the same issues.Thx, jake