# Get tag provider with {PathToParentFolder} in expression

**URL:** <https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [July 25, 2019, 9:28am UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869 "2019-07-25T09:28:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcarritt1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mcarritt1/32/4262_2.png) [@mcarritt1](https://forum.inductiveautomation.com/u/mcarritt1)\
**Post date:** [July 25, 2019, 9:28am UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/1 "2019-07-25T09:28:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [September 4, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/2 "2019-09-04T15:51:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 4, 2019, 4:39pm UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/3 "2019-09-04T16:39:23Z")

</div>

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}`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f2baa59bfe53f912ca75853f3dde103639bc9794.png)

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [September 4, 2019, 5:02pm UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/4 "2019-09-04T17:02:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 4, 2019, 6:05pm UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/5 "2019-09-04T18:05:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [October 14, 2019, 9:36am UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/6 "2019-10-14T09:36:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mcarritt1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mcarritt1/32/4262_2.png) [@mcarritt1](https://forum.inductiveautomation.com/u/mcarritt1)\
**Post date:** [October 14, 2019, 9:54am UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/7 "2019-10-14T09:54:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joseph.burns](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joseph.burns/32/61584_2.png) [@joseph.burns](https://forum.inductiveautomation.com/u/joseph.burns)\
**Post date:** [August 13, 2020, 7:06pm UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/8 "2020-08-13T19:06:48Z")

</div>

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:

```auto
# 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)

```

---

<div class="post-metadata">

**Author:** ![nnaik](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nnaik](https://forum.inductiveautomation.com/u/nnaik)\
**Post date:** [October 1, 2021, 10:15am UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/9 "2021-10-01T10:15:23Z")

</div>

Hi,  
How to get tag Path in 7.9 ?

---

<div class="post-metadata">

**Author:** ![jsorlie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jsorlie/32/3645_2.png) [@jsorlie](https://forum.inductiveautomation.com/u/jsorlie)\
**Post date:** [April 20, 2023, 11:57pm UTC](https://forum.inductiveautomation.com/t/get-tag-provider-with-pathtoparentfolder-in-expression/26869/10 "2023-04-20T23:57:23Z")

</div>

> [@mcarritt1](#):
>
> I discussed it with Inductive support at one point and they agreed that they thought it was strange the provider isn’t there

Grrrr.... bumping this because, FWIW, the fully-qualified (tag provider) is still missing from the [pre-defined UDT parameters](https://docs.inductiveautomation.com/display/DOC81/UDT+Parameters#UDTParameters-Pre-DefinedParameters) 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()`](https://docs.inductiveautomation.com/display/DOC81/system.tag.readAsync) and [`writeAsync()`](https://docs.inductiveautomation.com/display/DOC81/system.tag.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](https://forum.inductiveautomation.com/t/question-how-do-i-use-readasync-to-read-tag-value/22008/7) would be more (sw)elegant..

> [@\[Question\] How do I use .readAsync to read tag value](https://forum.inductiveautomation.com/t/question-how-do-i-use-readasync-to-read-tag-value/22008/7):
>
> make semi-generic callbacks by creating jython classes that implement the ` __callable__ ` special method, and supply an instance as the callback. Have the ` __init__ ` method save the state you need to carry your logic forward.
