Example: Portal PeopleCode

In looking through PeopleBooks, the portal API objects seemed a little sparse for examples. So, here is a quick example that might help others. The example opens a folder and prints some information about the folder.

Local ApiObject &session, &portal;
Local ApiObject &folder;
Local boolean &open;
Local ApiObject &permissions;
Local ApiObject &permission;
Local string &permList;
&session = %Session;
&portal = &session.GetPortalRegistry();
&open = &portal.Open("EMPLOYEE");
&folder = &portal.FindFolderByName("SOME_FOLDER_NAME");
MessageBox(0, "", 0, 0, "Authorized: " | &folder.Authorized);
MessageBox(0, "", 0, 0, "Visible: " | &folder.Visible);
MessageBox(0, "", 0, 0, "Parent Name:" | &folder.ParentName);
&permissions = &folder.Permissions;
&permission = &permissions.First();
&permList = "Permissions: (count=" | &permissions.Count | ")";
While All(&permission)
&permList = &permList | Char(10) | Char(13) | &permission;
&permission = &permissions.Next();
End-While;
MessageBox(0, "", 0, 0, &permList);

4 thoughts on “Example: Portal PeopleCode

  1. I ran this code in an Application Engine. To test, you can create a simple Application Engine with only one step and one action. Change the action type to PeopleCode and paste the code above in it.

    Next, you will need to find a folder on your system. You can do it by going to PeopleTools > Portal > Structure and Content. Browse to any folder and open (or edit it) to get the name.

    Once you have the name, change the line in the code to that folder name:
    &folder = &portal.FindFolderByName(”SOME_FOLDER_NAME”);

    Does this help?

  2. Nokia,

    You have to already have access PeopleSoft. You could possibly download PeopleSoft from the edelivery web site for trial purposes, but it is very involved to set it up.

    Once you have access to PeopleSoft, use Application Designer (the PeopleSoft IDE) to create a new Application engine. With the Insert menu, insert a new Step/Action. You will notice that this creates a SQL action; change the drop down from SQL to PeopleCode. Then, you can double click on the step and open the PeopleCode editor. From there, copy the code above in the post and paste it into the PeopleCode editor.

    As mentioned above, make sure that you change the line that has the folder name in it. You probably also want to open the properties for the Application Engine and choose “Disable Restart” on the last tab. Then, save the Application Engine and click the run (green stop light) button on the toolbar.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.