Tag Browser Filtering

Does anyone know how to get filtering to work for UDTs on the Tag Browse Tree component? I want to filter on tags that contain a specific string. using the components builtin filter function, I can filter on tag name, but that doesn’t help because if I have a tag with, for example, “PV” as a child element, all i can access is PV; I don’t know what the path to this item is, so i lose all my PVs, which defeats the purpose because you can’t historize a UDT, only its child elements.

So i also went as far as populating the historized tags’ Documentation metatdata with the tag path, but when I access this from the filter function, the returned property is blank, even though i can see it has populated correctly inside the designer’s tag browser.

Any ideas how I can make the component do what i need?

I also tried using a treeview to create a custom tag browser, but this cam with other issues (no drag drop which i need (from component to trend chart), very complicated coding required for my specific project etc), so i’d prefer avoiding this line of investigation.

The filter method is called for everything separately, both tags and folders. You need to check for a folder and let it through if it does (or might) contain a desired tag. Only for leaf tags should you do your name check.

Thanks for the quick reply, I am guessing folders and UDTs are synonymous in this context, from what you are saying. I still am unable to understand how to check if it is a folder, since I can’t find anything on the documentation on methods or properties that give me this for the tag object type.

Also, I have been able to filter out “folders” (UDTs) by the fact they contain the search string, but the problem is they then appear to be leaf nodes with no child nodes., so even if I can find out if it is a folder, I don’t see how this can then be used to filter out the child nodes, since when I process a child node using the filter method, I can’t tell if it is in that folder (UDT) either.

Also, are we talking about the same thing here? On reading again, you might be talking about actual folders, in which case I have none.

I’m assuming this can’t be done, rebuilt the component with a tree view

If you don’t filter at all, do the desired tags show up in the list? If yes, it can be done. Start by writing a filter that logs the details of each call instead of blocking anything. Inspect the log to determine what you need to compare to get the desired results.

Thanks @pturmel, but I have finished rebuilding a treeview that achieves what I want. I am still interested in if this is possible, because I feel I have tried everything, so if there is a way it would suggest there is something very useful to learn about ignition that I do not know (highly probable).

What I have tried:
What I think you are saying about logging the details of the function call is what I have tried, but to make sure we are talking about the same thing I will explain what I did: The function call only has one parameter, tag, which when converted to a string and printed to the console only has some parameters that are not of interest, such as name (many are the same since they are the child member names of the udt), tagtype (all seem to be 7), Enabled, AccessRights, TagType, DataType, and the qualified value.

I also found the api for what I think is the tag object that is passed into the filterTag method as a parameter here. It does not have a way that I can see of getting the path, which is what I want to filter on, since it will contain all parent tag names.

I have also tried getAttribute with the TagProp enumeration - but the tag prop enum also doesn’t have an element for referencing the tag path. So I decided to embed the information manually into the documentation field, which when retrieved in the context of the filterTag method, also does not work (just returns and empty value)

To me, that is the only information I can obtain at runtime for this component. Is there something else that can be done? I know the information I want is somewhere, because when I drag and drop the tag it parses to a path string, but I just don’t know if I can access it in the filterTag’s scope.

Yes, that is (officially) what you get. But if you print out the java class of that object, you'll find there's more to be had.
Anyways, your filter should look something like this:

def filterTag(self, tag):
	from com.inductiveautomation.ignition.common.sqltags.model import TagProp
	from com.inductiveautomation.ignition.common.sqltags.model.types import TagType
	# Report the real type of the tag parameter.  Comment this out before deployment.
	print tag.name, tag.getClass()
	if tag.type in (TagType.Folder, TagType.UDT_INST):
		# check the folder name or properties to decide whether the folder belongs
		return 'something' in tag.name
	# Retrieve the documentation for the leaf tag
	doc = tag.getAttribute(TagProp.Documentation).value
	return 'somethingElse' in doc