Example: Portal PeopleCode

This page has moved.  Please update your links:
http://psst0101.digitaleagle.net/2007/11/15/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);

Advertisements

4 Responses to “Example: Portal PeopleCode”

  1. A Siayed Says:

    Where and how can this program be applied. How can I test the program.

  2. digitaleagle Says:

    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?

  3. Nokia Says:

    how can i test this program? and where i get it?

  4. digitaleagle Says:

    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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: