Hello, I have a Named Query Parameter that I'm trying to update dynamically. Through some research I have read that I cannot call this information directly from a tag and have to pass it in through a Parameter.
I have created a Parameter in my Named Query called :INF but the issue I'm having is updating that value.
I can't find an example script to understand how to update that Parameter. For the moment all I want to do is update that Paramater with a tag value on button press. Both the Tag Value and Parameter are set to STRING.
Can anyone link me a post that has done something like this so I can force feed my brain this information lol or be kind enough to show me
What I have right now is a Named Query and a Tag Value I want passed. I was playing around with trying to update it on button press but it sounds like that's not the right way to go about it.
So it sounds like I need to run the query via script and define my parameter there to return a value and have it write to something?
Assuming you are binding on a custom prop or equivalent
tagValue = value #Value to pass in to named query...
params = {"INF":tagValue} #Asssign your tag value to the query parameter
system.db.runNamedQuery("yourQueryPath", params) #Run the named query and do something with the result
This is a simple script based of a tag binding, depending on what and where exactly you are trying to run this it could change a bit. you may have to run a tag read and assign that result to the parameter. Hopefully this helps a bit.
No, but how and where you are calling the named query from the approach may change. For instance, lets say you want the results to be shown in a table. You could create a custom property to bind the tag to. Then use a query binding on the table, with the parameter bound to the custom property. On the button click all you would need to do is refresh the binding on the table.
Depending on your needs there are several ways to accomplish the rather generic "use a tag value as a parameter". Just trying to get more information so I can provide an appropriate response.
Depending on the context of the call, you may need to include the project name. the Key in the params dictionary should match the parameter name, without the colon, exactly (case sensitive).