Get tag provider with {PathToParentFolder} in expression

Is there anyway to dynamically get the tag provider in a UDT expression tag?

I’m doing a runScript() and passing a tag path, but since expressions are gateway scoped, I have to add the tag provider. Is there anyway to do it dynamically? Seems weird it’s not there considering the options of having remote tag gateways.

1 Like

I’d like to bump this up because I ran into the same thing. I ended up creating a UDT parameter called “tagProvider” and then used it in the runScript function call like so…"[{tagProvider}]{PathToParentFolder}/mytag". I understand that the script is Gateway scoped, but a UDT is created inside a tag provider…and it should know how to reference itself. I also tried referencing the “[System]Client/System/DefaultTagProvider” tag, but it won’t resolve in the UDT’s expression.

I’m not positive this works in 7.9, but rather than needing to “know” the relative tag provider, you can just use a relative reference to it with the [~] provider syntax:, eg: {[~]Alarm Tag}

1 Like

Right. But this doesn’t work when trying to provide a path string as a parameter in a runScript() function call. Ultimately the runScript is calling a gateway scoped script…which needs the fully qualified path including tag provider if you plan on using paths for tag historian queries or others.

If you are looking to use it in templates with a UDT you can just script it to get the value.
On click of a part of the template’/NameOfSubTag.OPCServer’).value

I’m having the same issue.

To be able to perform a tag browse using this UDT’s path, a provider is required.

Did you find a solution?

no I didnt. I discussed it with Inductive support at one point and they agreed that they thought it was strange the provider isn’t there, but I never heard back any solution.

Here’s a really ugly way to find the tag provider’s name inside a UDT…

Create a memory tag in the UDT called “tagProvider”, and add this tag event script:

# The tagPath property contains the tag provider's name in brackets.
# The provider name is derived from the tagPath, then written to the value of this tag.
def qualityChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	providerName = tagPath[tagPath.find("[")+1:tagPath.find("]")]