117
Views
8
Comments
Grant roles by using switch
Application Type
Reactive

I have a list inside the list there are multiple switch button i want to given the particular role by using these switch button like when i select manager switch the manager role should be granted or when i select teamlead switch the teamlead role should be granted but the problem is these switch button are inside the list 

Role.oml
2023-09-27 09-11-46
Somil Nagar

Hello @Shubham kushwah ,

You can use the Granrole function for granting the role to a particular user. 

UserImage.jpg
Shubham kushwah

Yes but the problem is these switch button are inside the list i pass the variable value to switch button for grand employee role but when i click on the another switch button the employee logic working on all switch buttons

2023-09-27 09-11-46
Somil Nagar

So after that, you can revoke it also by using the revoke function. 

2022-08-03 04-32-50
Ravi Punjwani

Hi Shubham,

  • Inside your Switch1OnChange client action, add an input variable RoleId of type Role Identifier.
  • On the user interface in your list, select GetRoles.List.Current.Role.Id
  • Now you have a dynamic RoleId coming as input parameter in your Switch1OnChange event.

Then use that Role ID for granting the selected role.

For granting that role, insert a record in the entity User_Role of System module (check duplicate before adding) to play safe.

UserImage.jpg
Shubham kushwah

Can you please show me how to do that i dont understand

2022-08-03 04-32-50
Ravi Punjwani

Hi Shubham,

I won't be able to fix the OML file you shared.

You're using a custom created Role entity, which is not a recommended approach. If you modify your application to use the default Role entity which is provided in System module. Just reference it from your app, and delete your custom Role entity.

Once you're done with that part, send me the OML file again, I'll get the issue fixed for you.

UserImage.jpg
Shubham kushwah

that role entity i created for showing record inside the list for switch button  that entity has nothing to do with role

2020-11-25 10-45-32
Mostafa Othman
Champion

Hi Shubham,

I did number of changes into your oml.

I added onChange action for users dropdown list to refresh getRoles aggregate


I also added swithch to grant and revoke employee action which you can add more roles condition

 as per your application roles. Also I created new table called AppRole which its Id is SystemRoles table Identifier (I added Role_System table and user_Role from System module)

For the aggregate of returning roles (GetRoles) I did some changes

Kindly find updated oml attached


Role_Updated.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.