Need help passing value to determine which tag to use

Greetings,
I know this is simple but apparently I’m just having a case of Monday. I’ve created a shift start popup for my company in which our team leaders specify which line they are working on along with how many employees they are beginning their shift with. I have a folder of tags named “Employee Counts” and each line has it’s own tag that I’m wanting to set that value too on a button press.

What I currently have is:

l = event.source.parent.getComponent('Shift 1').selectedStringValue
value = event.source.parent.getComponent('emplbl').text

system.tag.writeBlocking(['[default]Employee Counts/{}',l], [value])

I’m trying to pass the line that the Team leader is selecting, into the tag path to determine which tag needs to be wrote to, and then pass along the actual amount of employees to that memory tag. It’s obviously failing, I just don’t know how to send that tag path through the script. Can anyone assist? Thank you!

Try this

l = event.source.parent.getComponent('Shift 1').selectedStringValue
value = event.source.parent.getComponent('emplbl').text
tagPath = "[default]Employee Counts/%s" % (value)
system.tag.writeBlocking([tagPath],[l])
1 Like

Hey man I appreciate the reply. This didn't kick up an error message, but it also didn't write to the tag so I have no idea. It's in read/write so I'm assuming It's on my end. Thank you for the reply though man I really appreciate it. I feel like this is the answer, I just need to figure out why it's not changing the value in the memory tag

Try adding print statements of your variables and tag path. It will print in the console accessible in the diagnostics dropdown menu. I bet one of the variables isn’t what you are expecting it to be.

l = event.source.parent.getComponent('Shift 1').selectedStringValue
value = event.source.parent.getComponent('emplbl').text
tagPath = "[default]Employee Counts/%s" % (value)
print 'l=' + l
print 'value=' + value
print 'tagpath=' + tagPath
system.tag.writeBlocking([tagPath],[l])

If that doesn’t help, make sure the tag you are writing to has the same type as variable l

1 Like

That’s exactly what it was, it was on the “value” end. Was completely my fault for not explaining very well, thank you for the help my man! Much obliged!

1 Like