Tags are not in a project, so cannot call any project resources. Only scripts in the shared.* namespace are usable. Also, you really need to get your code out of the legacy app.* namespace – it’s going away eventually, and its scoping rules create numerous headaches.
# Function used to return a dataset of tanks for a specific pad
# Used to populate the tank template repeater on the pad data page
# Takes an tagpath argument of PadRootFolder
def getTankDataset(PadRootFolder):
import system
path = PadRootFolder+"/Pad"
# Create the rows for the dataset
rows = []
tags = system.tag.browseTags(parentPath = path, tagPath = '*tank*_name', sort = "ASC")
row_count = 0
for tag in tags:
tag1 = system.tag.read(tag.path)
if tag1.quality.isGood():
tagName = tag.name
endChar = tagName.rfind("_name")
tagNum = tagName[4:endChar]
row_count += 1
newrow = [PadRootFolder, int(tagNum)]
rows.append(newrow)
#Create the dataset to send back
headers = ["PadRootFolder","TankNumber"]
dataSet = system.dataset.toDataSet(headers,rows)
return system.dataset.sort(dataSet, "TankNumber", 1)
Thanks Phil, I just attempted that but it still won’t execute the call. If i have to I can make the tags memory tags and write the dataset to them via script. But i feel like I shouldn’t need to do that.
Thanks for all the responses guys. I have been trying to get anything to show up in the gateway log and I’ve been unsuccessful.
Also, I have saved globally after creating that script. I do have other scripts in the same script library which I have been able to call in an expression tag without any problems. I’m still at a loss as to why this won’t work for me on my end.
Consider adding logging to your script module to locate exactly where it is failing. Include a log call at the global level at the end of the script module so you can confirm that it is fully loaded without top-level errors.