Component Scripting

Thanks again for all the help recently. Project is coming allong.
Todays question is about scripting. I have a button that when clicked moves several values to tags to be used in tables for a report. These values are dependant on the “Machine Name”, shown as “ID” in the script is the variable that needs to change dependant on the “Machine Dropdown” selection. Is there a way to do this with script

value = event.source.parent.getComponent(‘Machine Dropdown’).selectedStringValue
system.tag.writeToTag(“ID_Tooling/Machine_Name”, value)

Any better suggestion is welcome if i am going about this the wrong way… so wet behind the ears i leave a puddle.


You can concatenate strings will the plus (+) sign:

value = event.source.parent.getComponent('Machine Dropdown').selectedStringValue
system.tag.writeToTag(value + "_Tooling/Machine_Name", value)

But if this is for users to generate reports, you’ll almost certainly want to create a CLIENT tag instead (called, say, “ReportMachine”) and write to that:

value = event.source.parent.getComponent('Machine Dropdown').selectedStringValue
system.tag.writeToTag("[Client]ReportMachine", value)

Now your report queries can bind to the CLIENT tag in your SQL queries, etc.

You guys RULE!!! :prayer: