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.

2 Likes

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

system.tag.read(event.source.parent.NameOfUDT.Meta.TagPath+'/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("]")]
	system.tag.write(tagPath,providerName)
1 Like

Hi,
How to get tag Path in 7.9 ?

Grrrr.... bumping this because, FWIW, the fully-qualified (tag provider) is still missing from the pre-defined UDT parameters eg. {PathToParentFolder}. One would think that at least one of the pre-defined param's would include this. Judging from my 7.x UDTs of days past, it was this way then....

My work-around relearned from @joseph.burns 's post:

udt	= tag['parameters']
tagProvider = tagPath[1:][:tagPath.find("]")-1]
fullyQualified = lambda t: '[%s]%s/%s' % (tagProvider, udt['PathToParentFolder'], t)
...
tagPaths = [
	fullyQualified('myMemberTag')	# "[.]myMemberTag"
]

My use-case is referencing UDT member tags within system.tag.readAsync() and writeAsync() callback functions which only take the single asyncReturn argument. This relies on the callback()'s variable references having proper scope i.e. being hard-wired. @pturmel 's suggestion here Pass parameter to tag.writeAsync would be more (sw)elegant..