PeopleSoft related articles.

Roles, Permissions, and Users Assigned to Portal Content Reference or Component

Roles attached to a component (portal_uri_seg2) or content reference (portal_objname)

SELECT DISTINCT c.portal_name, c.portal_objname, b.rolename, e.descr
  FROM psroleclass b, psprsmperm c, psprsmdefn d, psroledefn e
    WHERE c.portal_objname = d.portal_objname
            AND b.classid = c.portal_permname
            AND b.rolename = e.rolename
            AND (d.portal_uri_seg2 = :1 OR d.portal_objname = :2);

Permissions attached to a component (portal_uri_seg2) or content reference (portal_objname)

Roles Assigned to a Component

The SQL will pull Roles assigned to a specific component.



PeopleSoft Sample Code is a book where members can share their knowledge with other PeopleSoft users by listing sample code/snippets, tips and techniques.

Some snippets are just syntax, and others are examples, functions and so on. You can review and enhance ones already submitted by using the comment form under each post.

Set Number of Links within the Portal Navigation

The picture below shows a Security folder and 2 sub-folders (User Profiles and Permissions & Roles). You can also notice that each sub-folder has 4 more links listed below it (in addition to the More... link). If you are wondering why 4 links and not 6 or 10 links, well, it is 4 links because this is what I want it to be.

How can you set the number of links available under a Portal folder?
Navigate to PeopleTools > Portal > Portal Utilities > System Options and update "Maximum Child Links" to 4.

HideAllRows Hides Grid on a Page

I have been used to turn to HideScroll and UnHideScroll functions to hide/unhide grid on a page. These two functions however, remain for backward compatibility only.

The functions have been replaced by HideAllRows and ShowAllRows methods. The methods are equivalent to a loop setting the visible propertly of each row of the rowset to false.
For the code to work though, you need to place your peoplecode in a parent rowset and execute it against a child rowset.

Read a File Using File Layout

A sample code to read a file using file layouts and insert data read into a record.

Local File &MYFILE;
Local Record &REC;
Local array of string &ARRAY;
Local string &FILE_DIRECTORY, &FileName;

&FileName = "MY_FILE_NAME.txt";
/*open file for reading*/
&MYFILE = GetFile(&FILE_DIRECTORY | &FileName, "R", %FilePath_Absolute);
/*create record object*/
&REC = CreateRecord(Record.MY_RECORD);
&ARRAY = CreateArrayRept("", 0);
/*check if file is open*/
If &MYFILE.IsOpen Then

Users and Emails Under a Certain Role

The query will help you find users with their email addresses for a certain Role Name.

SELECT emailid
FROM psoprdefn
, psrolemember
WHERE rolename = :role_name
AND oprid = roleuser
AND emailid <> ' '

For example, you could run the query to get email addresses for users who have a role name of "Developer".

Email Users Under a Specific Role Name

Here is a quick Application Engine section that looks up user's email addresses under a certain ROLE and sends an email notification regarding, well, what ever you'd like.

send email for a specific role

First, you would need a "Do Select" step to loop through the email addresses (if more than one) and call the PeopleCode step below it to send the email. Your Do Select should have the following SQL:

-- you need to store the email address for the peoplecode step to use and thus the %Select(EMAILID).

Dynamic View and Drop Down Menu

This was kind of interesting to figure out. What I was going after is the following. I had a drop down box on a page that shows some Business Units. The values however need to be dynamic and change depending on the user viewing/accessing the page.

For example, user1 should only see 52024, 12456 but user2 should be allowed to see 52024, 12456, 45648, and 10235.

To accomplish this I've created a table to store values for each user (lets call it TABLE_1). TABLE_1 has 2 fields (oprid, and business_unit). So now, we have 2 users on the table along with their associated business units.

The 2nd step is to create the dynamic view to pull business units specific to each user. The view will only have one field and that is the business_unit field.

record view

Check for User Role

A very handy PeopleCode function to check for a user role(s) and perform specific actions depending on the value returned.

Function RoleToMatch(&RoleToMatch) Returns boolean;
   &bFound = False;
/*Returns an array containing all roles associated to the current user*/
   &aRoles = %Roles;
/*Loop through the array*/
   For &I = 1 To &aRoles.Len
      &RoleName = &aRoles.Shift();
      If Upper(LTrim(RTrim(&RoleName))) = Upper(LTrim(RTrim(&RoleToMatch))) Then
         &bFound = True;
   Return &bFound;