Saturday, September 13, 2008

Checking a Peron's Roles within PeopleCode

For manually securing object or doing some kind of filtering, it is regularly useful to know what roles a person has in their user profile. Peoplesoft provides a global variable to give you access to the person’s roles.

Example:

Local array of string &Roles;

Local integer &I;

&Roles = %Roles;
&doTransfer = True;

For &I = &Roles.Len To 1 Step - 1
If &Roles [&I] = "My Special Role" Then
&doTransfer = False;
End-If;
End-For;

2 comments:

Banksy said...

You could also use

If IsUserInRole("rolename") Then

Tim McLaurin said...

Abosultly agree, thanks for point that out! But for some reason I have had limited success with that function. Using the loop also gives a little for flexability...
Thinking multiple matches and/or complex logic....