Toggle Switch Question

Good morning Team,

Hopefully a simple question this morning.

I have created a toggle switch that runs a namedQuery to update a db with a simple enable or disable feature.

My question is: Is there a way to have the the script I created read the db once the screen is open in order to ensure the toggle switch is set to the correct mode, either disabled or enabled?

UPDATE storage
SET data = :data
WHERE attribute = 'Crane_6_P1_Enable'


data = self.props.label.text
	category = "HMI"
	source = "ASCADA Client"
	usr = self.session.props.auth.user.id
	message = str(usr) + " Changed Crane 2 to   " + str(data)
	data9 = usr 
					
				# Update Crane Mode
	system.db.runNamedQuery("CFG Queries/crane_2_enable_mode",{
				"data": data
					})
					
				#Update Syslog		
	system.db.runNamedQuery("Tables/syslog_update",{
				"category": category,
				"source": source,
				"message": message,
				"data9": data9
					})


Are you aware that you can create a query tag in the tag browser? It can return all the usual datatypes for you. This should simply matters for your application.

I was but I forgot about them. I am not entirely sure how to configure one.

Should I create a query tag like this? And then bind this to the value of the toggle switch so when it opens it will update with the value?

SELECT
    Clemens.storage.data
FROM
    Clemens.storage
WHERE
    Clemens.storage.attribute = 'Crane1_PutAway_Enable' ;


That looks OK. You’re going to add that into the query tag definition. Here’s my test which seems to work. Set the execution mode and update rate to something sensible.


Can you remove the “details” section from your post. It may confuse future readers.

Thank you so much for the help and guidance. Here is a pic of what I am designing. My first project, thoughts?