Issue with lookup() in tag change script

I'm trying to use lookup() in a tag change script to assign a string value to a memory tag based on the results of a lookup in a dataset tag.

My script is showing an error in the Ignition gateway and is not running.

I suspect it is a syntax error with the way I am referencing the dataset tag. I tried running the script with line 3 commented out (and writing a random value to dl_fx instead of 'dl_ID_line1'), and the script was able to run fine.

For context, [edge]CLICK_values/Line1/DL_ID is equal to 4, and the data type of that tag matches the data type of the DL_ID column in the dataset (both are integers).


Oops, I sent a screenshot of my debugging version of the script.

The value written to dl_fx in Line 4 should be dl_FX_line1

lookup() is an expression function, not a scripting function. You need to extract the key column as a list, then use .index(), then retrieve the desire value.

2 Likes