Thursday, May 10, 2007

Find if the current user has been assigned the named role

You can use this in your peoplecode to determine if the current logged in user has role assigned to him.

&IND = %Roles.Find("MYROLENAME");

IF &IND <> 0 Then

     /* User has this Role */

or 

   /* User does not have this Role */

end-if

You can also use the peoplecode function IsUserInRole("ROLENAME") to find the same.

2 comments:

josephus said...

This is cool. No2 is there a way to query the current user either through PS Query or SQL?

Ketan Kothari said...

select * from psroleuser where roleuser = [userid]

replace [userid] with actual userid.