# Calling a System tag from a template

**URL:** <https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [August 10, 2022, 2:33pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873 "2022-08-10T14:33:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrutten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mrutten](https://forum.inductiveautomation.com/u/mrutten)\
**Post date:** [August 10, 2022, 2:33pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/1 "2022-08-10T14:33:38Z")

</div>

Is it possible to read a system tag in a template and see the value in the designer in run mode?  
I am trying to read the [System].Client.User.RoleString, but in the designer in run mode it gives me a “None” value eventhough the tag has “Administrator” value?

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 10, 2022, 4:00pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/2 "2022-08-10T16:00:17Z")

</div>

How did you bind it? Works for me.  
Does it work in the designer?

---

<div class="post-metadata">

**Author:** ![mrutten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mrutten](https://forum.inductiveautomation.com/u/mrutten)\
**Post date:** [August 10, 2022, 9:36pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/3 "2022-08-10T21:36:28Z")

</div>

I used below concept  
`server ` `=` `"Ignition OPC UA Server"`

`path ` `=` `"[SLCSim]_Meta:N7/N7:0"`  
`qualifiedValue ` `=` `system.opc.readValue(server, path)`  
`print` `"Value: "` `+` `str` `(qualifiedValue.getValue())`  
`print` `"Quality: "` `+` `qualifiedValue.getQuality().toString()`  
`print` `"Timestamp: "` `+` `qualifiedValue.getTimestamp().toString()`

But now I have changed my code to do the following what seems to work.  
roles = system.user.getRoles(“”)  
for role in roles:  
if role == “Administrator”:  
RoleAdmin = True  
else:  
RoleAdmin = False

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 10, 2022, 10:01pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/4 "2022-08-10T22:01:42Z")

</div>

Do you need the true false, or just the role displayed?

---

<div class="post-metadata">

**Author:** ![mrutten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mrutten](https://forum.inductiveautomation.com/u/mrutten)\
**Post date:** [August 10, 2022, 10:09pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/5 "2022-08-10T22:09:00Z")

</div>

Actual my code is not working. it will always result in True because I have a role that is “Administrator”

What I am trying to accomplish is to check in the template if the current user has a role as  
“Administrator”. This can be a true/false flag.

That was the reason I was trying to read the [System]Client.User.Rolestring.Value

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 10, 2022, 10:11pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/6 "2022-08-10T22:11:40Z")

</div>

But why do you need to know the users role? also you can test with a generic user you create.

What are you trying to do/hide/ etc…?

---

<div class="post-metadata">

**Author:** ![mrutten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mrutten](https://forum.inductiveautomation.com/u/mrutten)\
**Post date:** [August 10, 2022, 10:14pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/7 "2022-08-10T22:14:02Z")

</div>

The reason is that if the user has a role status of “Administrator”  
the user will be able to change the size of a circle and a bunch of more stuff, but if the user does not have that status of “Administrator” then he will not be able to see the components to change the size of a circle and a whole bunch of other stuff.

---

<div class="post-metadata">

**Author:** ![mrutten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mrutten](https://forum.inductiveautomation.com/u/mrutten)\
**Post date:** [August 10, 2022, 10:15pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/8 "2022-08-10T22:15:34Z")

</div>

So the role will be used to hide or unhide components.

---

<div class="post-metadata">

**Author:** ![mrutten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mrutten](https://forum.inductiveautomation.com/u/mrutten)\
**Post date:** [August 10, 2022, 11:03pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/9 "2022-08-10T23:03:55Z")

</div>

After some digging I am getting closer. I was on the wrong track. Now I have this code but the line  
Roles = user.getRoles fails? I am not sure why

userName = system.security.getUsername()  
print “userName : " + userName  
if userName == “Ignition”:  
user = system.user.getUser(”", userName)  
Roles = user.getRoles

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 12, 2022, 12:41am UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/10 "2022-08-12T00:41:36Z")

</div>

When you add code, you need to use the pre-formatted block otherwise the text loses all formatting ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/b/bb9f3ce0680ddb3d0f8bfd33882cc0aef678313f.png)

Also,

> [@mrutten](#):
>
> Now I have this code but the line  
> Roles = user.getRoles fails? I am not sure why

We're not sure why either, as you haven't given us the error message 🙂

In scripting, to get the currently logged in user's roles you can use:

```auto
system.security.getRoles()

```

`system.user.getUser` requires the user source, you can't just leave this blank.

If you want to use it in an expression though, you should be able to read the tag `[System]Client/User/RolesString` as you said. You had dots instead of slashes though?  
This is the error I get trying to read that tag path with dots instead:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/6/96c7ec63365df4eb3db75e8dd6ece10084d86371.png)

---

<div class="post-metadata">

**Author:** ![mrutten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mrutten](https://forum.inductiveautomation.com/u/mrutten)\
**Post date:** [August 12, 2022, 4:21pm UTC](https://forum.inductiveautomation.com/t/calling-a-system-tag-from-a-template/62873/11 "2022-08-12T16:21:11Z")

</div>

> [@nminchin](#):
>
> `system.security.getRoles()`

Thank you Nick.  
It works.  
That was much simpler then what I was doing.

Also thank you for the code formatting tip. I am new to this forum and this will help me.

Marcel.
