Instantiating ProcessRequest(): Arguments Matter

PT 8.62

Randy Groncki

The short version

if you plan to use ProcessRequest() methods, pass the process type and process name to CreateProcessRequest when you instantiate the object.

Arguments Matter

ProcessRequest is a PeopleCode object that we use to programmatically schedule a process or job through the PeopleTools Process Scheduler.

It matters how you instantiate the ProcessRequest PeopleCode Object.

For our demonstration, we’ll assume that we have a page with a button that submits a query to batch.

The PeopleCode is attached to this button’s Record Field FieldChange event.

Old Way

You will probably see older PeopleCode that looks like this:

Local ProcessRequest &processRqst;
Local integer π 

/* instantiate object */
&processRqst = CreateProcessRequest(); 

/* set parameters */
&processRqst.ProcessType = “Application Engine”;
&processRqst.ProcessName = “PSQUERY”; 

&processRqst.RunControlID = “X”;
&processRqst.RunDateTime = %Datetime;
&processRqst.OutDestType = “WEB”;
&processRqst.OutDestFormat = “XLS”; 

/* schedule process */
&processRqst.Schedule(); 

/* show user the ProcessInstance */
&pi = &processRqst.ProcessInstance;
MessageBox(0, “”, 0, 0, “Scheduled Query, Process Instance: %1”, &pi);  

And this works fine. It submits the PSQUERY Application Engine program to the Process Scheduler with the following options:

  • Existing Run Control value = “X”
  • Run as soon as possible
  • Output to the Report Manager
  • Generate an Excel Spreadsheet

The user clicks the button.   The process is scheduled.  And the user receives confirmation through a popup message box with the new Process Instance.

Problems with this Old Method

This works great until you need to further modify the options of this process by using the ProcessRequest Object’s methods.

Example

We want to make the output of this job available to several users, not just the user clicking the button and submitting the process.

The ProcessRequest object has an AddDistributionOption() method that is built specifically for this need.

Here is that same code with two PeopleSoft users added to the report’s distribution:

Local ProcessRequest &processRqst;Local integer π

 /* instantiate object */
&processRqst = CreateProcessRequest();

 /* set parameters */
&processRqst.ProcessType = “Application Engine”;
&processRqst.ProcessName = “PSQUERY”; 

&processRqst.RunControlID = “X”;
&processRqst.RunDateTime = %Datetime;
&processRqst.OutDestType = “WEB”;
&processRqst.OutDestFormat = “XLS”; 

&processRqst.AddDistributionOption(“User”, “BLOCHERTY”);
&processRqst.AddDistributionOption(“User”, “PT3”); 

/* schedule process */
&processRqst.Schedule(); 

/* show user the ProcessInstance */
&pi = &processRqst.ProcessInstance;
MessageBox(0, “”, 0, 0, “Scheduled Query, Process Instance: %1”, &pi);

We are adding the users “PT3” and “BLOCHERTY” to the distribution.

But when the user now clicks the Schedule Query button, we get the following error:

The old pattern creates a generic ProcessRequest and assigns the process type and process name afterward. That is enough to schedule the process, but it does not fully initialize the object for methods such as AddDistributionOption().

Instantiate the new right way

If we want to use the available properties and methods of the ProcessRequest object, we need to pass the process type and process name during instantiation instead of assigning them later as properties.

&processRqst = CreateProcessRequest(“Application Engine”, “PSQUERY”);

Here is the event code instantiating the ProcessRequest object the newer, correct way.

Local ProcessRequest &processRqst;
Local integer π 

/* instantiate object */
&processRqst = CreateProcessRequest(“Application Engine”, “PSQUERY”); 

/* set parameters */
&processRqst.RunControlID = “X”;
&processRqst.RunDateTime = %Datetime;&processRqst.OutDestType = “WEB”;
&processRqst.OutDestFormat = “XLS”; 

&processRqst.AddDistributionOption(“User”, “BLOCHERTY”);
&processRqst.AddDistributionOption(“User”, “PT3”); 

/* schedule process */
&processRqst.Schedule();

 /* show user the ProcessInstance */
&pi = &processRqst.ProcessInstance;
MessageBox(0, “”, 0, 0, “Scheduled Query, Process Instance: %1”, &pi);

The user now can click on the Schedule Query button and the code successfully submits the process to the Process Scheduler.

In the Process Monitor, we can look up the parameters of this request and see that our defined users are in the distribution list.

PeopleBooks

PeopleBooksPeopleTools 8.63 PeopleCode API Reference

Randall Groncki

Oracle ACE ♠ PeopleTools Developer since 1996 Lives in Northern Virginia, USA

View all posts by Randall Groncki →

Leave a Reply

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