# Need to set Role based access via scriptings

**URL:** <https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [November 5, 2024, 11:57am UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198 "2024-11-05T11:57:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [November 5, 2024, 11:57am UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/1 "2024-11-05T11:57:20Z")

</div>

I have UI screen where "Admin" of gateway need to select the options of modules/view they can able to access based on the role.  
Example:  
I have settings, Reports screen. While creating user and roles, he need to assign what are screen he can assign.  
User- op1, Role-operator, Screen can access - settings  
User- op2, Role-operator, Screen can access - Reports  
We can add as developer in gateway/in each view/in each component. But admin need to add in UI how new user and role has been added in views.  
Hope I have clearly explained the need!  
any idea can be done via scripting using system functions?Kindly help

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [November 5, 2024, 12:55pm UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/2 "2024-11-05T12:55:44Z")

</div>

[system.user | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-user)

These system functions will allow you to add/edit users and roles directly from project and event scripts, which will allow to achieve the functionality I think you're looking for from your Perspective project.

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [November 5, 2024, 1:29pm UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/3 "2024-11-05T13:29:05Z")

</div>

Thank you for your reply. I can able to add roles here.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/a/7ad9cd02fe094f54f62c398f8545d6e2e4ec28d1.png)  
But I need to make role based access for that screens.  
Example: op1 only have access to view1  
op2 only have access to view2.  
Like need to done in script instead of doing here  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/060831ff94186e0135022177ea028ccd23fc0485.png)

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [November 5, 2024, 1:52pm UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/4 "2024-11-05T13:52:48Z")

</div>

Ok, I think I understand. I am not aware of way to do this exactly how you would like (not saying it's impossible I just don't know).

But a solution to this could be to create a single role for each individual screen and then configure those in the view permissions ahead of time. Then you could allow the Admin to add/remove those roles to users in your existing view. This might not be the most scalable solution, but it should work like how you are describing it.

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [November 6, 2024, 5:31am UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/5 "2024-11-06T05:31:38Z")

</div>

Thank you for your reply. Understand your input. But still I am searching for my solution.  
Any other inputs are welcome

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 6, 2024, 8:55am UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/6 "2024-11-06T08:55:37Z")

</div>

I don't understand what you are trying to do.

> have UI screen where "Admin" of gateway need to select the options of modules/view **they can able to access** based on the role.

The admin can access everything. I think you mean "that the **user** can access".

The normal way to do this is:

- In Designer decide what **roles** can have access to a view.
- In User Management assign **roles** to **users**.

Normally Users and Roles are configured on the gateway web page. A much easier way is to include the _Perspective User Management by IA Sales Engineering_ module which is freely available on the Ignition Exchange.

Include this module in a view in your project. Of course, only administrators should have access to this view.

> **[Ignition Exchange](https://inductiveautomation.com/exchange/2128/overview)**
>
> Discover, share, and download community made Ignition resources in collaboration with your organization or the Ignition community.

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [November 6, 2024, 2:56pm UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/7 "2024-11-06T14:56:06Z")

</div>

Thank you for your reply, Yes we reused the same .  
may be I am confusing,  
Just need to give access to respective module based on the role in UI part not by backend designer part.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/5/151f45112fcd92387c43a168950c7a085e86ae2a.png)  
In above image, I will create the user and assign the role , while assign role i need to select options to view/edit dashboard for user according to the role.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 6, 2024, 3:47pm UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/8 "2024-11-06T15:47:24Z")

</div>

> [@srinivasan\_s](#):
>
> Just need to give access to respective module based on the role in UI part ...

Ignition's Users and Roles (and _Perspective User Management_ module) will do that for you. It's already part of Ignition and not just for the gateway. You can use it in your Perspective applications too.

You are re-inventing something you already have!

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [November 11, 2024, 4:46am UTC](https://forum.inductiveautomation.com/t/need-to-set-role-based-access-via-scriptings/98198/9 "2024-11-11T04:46:02Z")

</div>

Thank you for your reply. Understand. Will work on it.
