The PeopleTools Component Object Model

By Chris Malek | Tue, Mar 20, 2012

In order to be an effective PeopleSoft developer, you should commit to memory the PeopleTools object hierarchy. Specifically, you must understand how all of the following objects relate to one another:

  • Field
  • Record
  • Row
  • Rowset

It is also important to be very familiar with the documentation of each of the classes. You don’t have to memorize every property and method but you should be familiar with the majority of them and know where to quickly find the documentation in PeopleBooks. All the classes are documented in the PeopleCode API Reference.. You should have this bookmarked and should have read through it a few times so you understand the structure.

PeopleTools Component Object Rules

Here is some verbal rules of how the Component Objects relate to one another. You should be able to recite these in your head.

  • A Rowset can belong to a Rowobject.
  • A level zero Rowset object has one and only one Row object.
  • A Rowset can have one or more child Row objects.
  • A Row can have one or more child Record objects.
  • A level zero Row (for which there is only one) can have many Record objects.
  • A Row has one parent Rowset object.
  • A Record belongs to one Row object.
  • A Record has one or more Field objects.
  • A Field belongs to one Record object.

If you start from the lowest level Field and go to the highest level Rowset object the object hierarchy is as follows: A Field belongs to a Record that belongs to a Row that belongs to a Rowset.

Traversing the Component Object Hierarchy with PeopleCode

Once you have a mastery of the Component Object hierarchy you can begin to write code the exploits these relationships. Let’s say you have a function that accepts a Field object as a parameter. The function may be stubbed out like this.

function psObjectTraversal(&fld as field)

end-function;

Since psObjectTraversal takes a Field object as a parameter that means that we can ask all sorts of useful information about the parent objects for this field at runtime. For example, you can easily get the record object that holds this field using the ParentRecord Field property.

function psObjectTraversal(&fld as field)
  local record &recParent;
  &recParent = &fld.ParentRecord;
end-function;

That was pretty easy. Now let’s assume that you want to do something in this function only if the Record containing the Field has EMPLID defined as a key field. How would we do this? It is actually very easy.

function psObjectTraversal(&fld as field)
  local record &recParent;
  &recParent = &fld.ParentRecord;

  local field &fldEmplid = &recParent.getfield(Field.EMPLID);

  if all(&fldEmplid) and &fldEmplid.isKey then

     /* Do something interesting because EMPLID 
        is on the record and is a key */

  end-if;
end-function;

Now let’s assume that you only want to do something in this function if the Field parameter is in a Record that is on a Row with a number of 1. (i.e. The first row.). This is actually very easy too.

function psObjectTraversal(&fld as field)

  if &fld.ParentRecord.ParentRow.RowNumber = 1 then

    /* Do something Interesting because we are on the 
        first row of a rowset */

  end-if;

end-function;

Let’s go a step further and say we only want to do something in this function if the Field passed in is in a level zero Rowset. This is crazy easy too!

function psObjectTraversal(&fld as field)

  if &fld.ParentRecord.ParentRow.ParentRowSet.Level = 0 then

    /* Do something Interesting because we are on the 
        level zero rowset */

  end-if;

end-function;

These are some simple examples of how to traverse the object model. You can also combine these with the PeopleCode Current Context functions to create some pretty dynamic code.

Here are some things to try for homework with the psObjectTraversal stub function.

  • Make the function check to see if the Field passed in has a Record object in the same Row that is derived.
    • Hint: Get the parent Record and Row then loop through all the child Record objects.
  • Make the function check to see if the Field passed has a PSOPRDEFN Record on the same Row
  • Make the function check to see if the Field passed in belongs to a Rowset that is based on the PSOPRDEFN Record
Article Categories
Author Info
Chris Malek

Chris Malek is a PeopleTools® Technical Consultant with two decades of experience working on PeopleSoft enterprise software projects. He is available for consulting engagements.

About Chris Work with Chris
Looking for pain-free PeopleSoft web services? 😀
PeopleSoft Simple Web Services (SWS)

Introducing a small but powerful PeopleSoft bolt-on that makes web services very easy. If you have a SQL statement, you can turn that into a web service in PeopleSoft in a few minutes.

Book
Integration Broker - The Missing Manual

I am in the process of writing a book called "Integration Broker - The Missing Manual" that you can read online.