About the Check..Role() function

Hi there.


I would like to switch the user role with clicking a button.

For example, I want change the role of user1 to B role. And change back to the A role by clicking the button again. (Updating with UpdateUser_Role Action)

Before update the user role, there is a conditional like below.

If(CheckARole(GetUserId()), GetRoleId("B"), GetRoleId("A"))


It works well at the first time, but it doesn't work well from second time....

It seems that CheckARole(GetUserId() function returns "false" even though the user has the A role.


Is this like this?

Or am I writing wrongly?


Thanks in advance.

Best Regards.


Hi,

One question, would you like to be with a user who had a Role and after he changed Role. Got it?

Grant and Revoke End User Roles

You need to work with Grant and Revoke Role, as I show you in the documentation above.

Then tell me if this is what you want, if you don't elaborate a little more!

Cheers,
Nuno

PS.: Check this post too.

Nuno Miguel Verdasca wrote:

Hi,

One question, would you like to be with a user who had a Role and after he changed Role. Got it?

Grant and Revoke End User Roles

You need to work with Grant and Revoke Role, as I show you in the documentation above.

Then tell me if this is what you want, if you don't elaborate a little more!

Cheers,
Nuno

PS.: Check this post too.

Thank you for your reply.

What I would like to is switching the user role manually like second document you showed me.


I guess it works correctly to revoke and grant the user role in the current way.

Before doing it, I check the current user role.

If the user has A role, change A to B.

If the user has B role, change B to A.

That’s why I wrote below.

(With the assumption, users only have A or B role.) 

If(CheckARole(GetUserId()), GetRoleId("B"), GetRoleId("A"))


But as I said before, following function returns “false” even though user has A role...

CheckARole(GetUserId())


Once logout from the app, it works well again...


Best Regards.



Solution

Try this, I will write in pseudo code.

If the user is Role A (CheckARole(GetUserId()) = "A"), then I Revoke A and Grant B, if not A, I Revoke B and Grant A.

Do you understand what I'm trying to explain to you?

Solution