> For the complete documentation index, see [llms.txt](https://docs.guardianservice.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.guardianservice.app/technical-information/library-of-policy-examples/creating-and-using-roles.md).

# Creating and using Roles

For a demo example of following steps, here is the policy timestamp: **1675164531.823309003**

### **User roles usage in Policies**

#### **An example of creating and using Roles in Policy**

1. Switch to the Roles tab

<figure><img src="/files/Du6J6FLrLMlgzkjfTTll" alt=""><figcaption></figcaption></figure>

2. Create 2 new roles called ‘**Example role 1***’ and* ‘***Example role 2***’

<figure><img src="/files/CKBYfueEftIp2z48nNAo" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/i71N7bSUVfcApRce8Oe7" alt=""><figcaption></figcaption></figure>

3. In the root container create 4 more ’**interfaceContainerBlock***’* container called ‘**no\_role***’*, ‘**owner***’*, ‘**role\_1***’ and ‘***role\_2***’*

![](/files/vy0zDOzeFTC615jF47KW)

{% hint style="info" %}
**Note:** By default all containers would have ‘*Any Role’* set and thus they would be visible to all users (with all roles)
{% endhint %}

4. Change the ‘Permissions’ properties in each container in the following way:

* no\_role: No Role
* owner: Owner
* role\_1: Example role 1
* role\_2: Example role 2

<figure><img src="/files/zrXdVTfHJXWkkXP09nsT" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/NY19MuwTSBljKnVONq1O" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/jzD98VWFbsrSjfFEN3l2" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/9BQ1TMVaUtDRo9ViSS5z" alt=""><figcaption></figcaption></figure>

This would result in the following visibility of containers:

* The first container (called ’no role’) would be visible only to new users which have no role assigned to them
* The ‘owner’ container would be visible only to the Standard Registry which created (or imported) this policy
* The ‘role 1’ container would be visible only to users with ‘*Example role 1’*
* The ‘role 2’ container would be visible only to users with ‘*Example role 2’*

5. Add a ‘**policyRolesBlock***’* to the ‘*no\_role’* container and name it ‘*choose\_role’*

<figure><img src="/files/8fDEPXBiRwP515MpSc8P" alt=""><figcaption></figcaption></figure>

Since this block is located inside the container ‘*no\_role*’ which has ‘*No role*’ permission setting it would only be visible to new users without an assigned role.

6. The ‘**Available Roles***’* property allows to configure which roles would be available to users to chose from at this stage of the Policy workflow

Select ‘**Example role 1***’ and* ‘**Example role 2***’*

<figure><img src="/files/XJEI2e9GTDuVze0GricG" alt=""><figcaption></figcaption></figure>

7. Add ‘**informationBlock**’ to other containers just to display results

<figure><img src="/files/HpVU2ntBgIALGA3RrXdi" alt=""><figcaption></figcaption></figure>

#### **Results**:

1. New users would end up on the policy choice form upon entering the policy

<figure><img src="/files/gWxWYRORU6lBQbTrjQpJ" alt=""><figcaption></figcaption></figure>

2. After the selection of the role users would see only 1 container corresponding to their roles

<figure><img src="/files/9LqfRSJbsEgIWkwgHE7f" alt=""><figcaption></figcaption></figure>

3. The owner of the Policy (the Standard Registry user) upon executing the policy would skip the role selection form and would immediately end-up in the corresponding container

<figure><img src="/files/s4KEXMMgRwTpenz6aqkl" alt=""><figcaption></figcaption></figure>
