I have a tag structure like folder/subFolder/udtTagList.
I want to get one tag from all UDTs of a certain type to display in a drop down. ie:
folder/subFolder1/udtTag1.tagName
folder/subFolder1/udtTag2.tagName
folder/subFolder2/udtTag1.tagName
where all “tagName”s are the same.
Once I have that, I want to display the list of “tagName” in the drop down. Is this possible?
See if you can use the designer's tag report tool tool to find your tags. Path would be */tagName.
When it works, you can export the search as a script snippet that could be tweaked to include in your UI.
I actually did it with this script:
objArray = []
tagList = system.tag.browse({folder}, {'recursive':True, 'name':{tagName}})
for tagDict in tagList:
value = str(tagDict['value'].value)
objArray.append({'value': value, 'label': value})
self.getSibling("Dropdown").props.options = objArray
system.tag.browse() is terribly inefficient compared to system.tag.query(). You should consider refactoring.
Phil, can you explain more please? I find that browse is quite a bit faster than query.
In this specific case, the OP is using browse recursively. That has historically been a disaster. If you have timing that shows the opposite, I'd be interested.
I don't, just going from memory (which isn't very good).
@nick.minchin might have something as I think he's said something similar in the past.
When I was making my tag report exchange resource, I implemented recursive caching of tag folders by tag provider. The initial implementation used system.tag.browse and was horrible. It became about 50x faster when I refactored to use system.tag.query.
I agree with Phil after numerous different systems/scripts doing this kind of thing.
It also appears that the op is using this on individual folders and not entire tag providers.
Which will of course not show any real delay on smallish tag amounts.
I am using this on one folder within one tag provider. I added the recursive because there are subfolders that I need to search. It’s also a small set of tags (a couple hundred).