ComponentInterfaceSaveAs/HowToEnable

Enabling Save As

Pick a Component

In this example, we will show how to enable Save As functionality on one of the test components, GS_SAVEAS_TST0, that is in the GS_CI_SAVE_AS Application Designer project. The technique will work with any PeopleSoft component though.

Here's what the test component looks like to start with.

Component without Save As

Here's what it looks like after enabling the Save As functionality and saving the current value as DEF. After filling in DEF on the original component and clicking "Save As", the existing data was copied into the new instance, and then the new window was opened with the newly created DEF key value.

Save As in action

Select (or create) a Component Interface based on the Component

Although end-users are not aware of the fact that component interfaces are being used to implement the "Save As" functionality, the PeopleTools Component Interface technology is the key piece to making Save As work. When someone selects "Save As" in the online page, the underlying PeopleCode uses a Component Interface based on the current component and instantiates two instances of it; one for the existing data (based on the current component's key values) and one for the copy of the data.

Our first task to enable a component for Save As functionality is to find or create a component interface based on that component. You can check to see if there is an existing component interface by opening the component in Application Designer and selecting Edit->Find Definition References from the menu. To be suitable for Save As functionality, the component interface needs to have Create and Get methods, and needs to have all of the fields that are needed to save a new value. An example of a PeopleSoft delivered component interface that is not suitable is the USERMAINT_SELF component interface. It only allows updating the fields in the underlying component; not adding new values.

If there is not an existing component interface, then you can create a new one. Select File->New from the Application Designer menu. Then select the underlying component. In our example here, the underlying component is GS_SAVEAS_TST0. When prompted about whether you want to default the component interface for all of the underlying fields or not, select Yes. Then save the component interface. In the example here, we named the CI with the same name as the underlying component.

Create a work record for Level 0 keys

We need to prompt the end-user for the new key value(s) when doing a Save As. We'll need a work record to hold those values. The requirements for the work record are

  • The work record has the required level 0 key fields for the component.
  • The fields are not marked as required. The fields can't be marked as required, because otherwise the PeopleTools component processor will mark the fields as being required when someone is trying to save data in the component and they are not actually doing a Save As. Don't worry though; the checks for whether the required fields have been filled in will happen when someone actually clicks the "Save As" button so we're not bypassing any edits here.

Set PeopleCode defaults

In the FieldDefault event for one of the fields in the work record that you created in the previous step, set the following 3 fields:

  • GS_CI_UTILS_WRK.BCNAME must be set to the name of the Component Interface that you created.
  • GS_CI_UTILS_WRK.RECNAME must be set to the name of the copied level 0 record (but not the actual level 0 record for the component).
  • GS_CI_UTILS_WRK.PANELNAME is optional. This is the page in the component that will be displayed after the Save As. The Save As logic pops open a new window with the new data. If this value is not set, the new window will just display the current page (which is the "Save As" page, which is not so user friendly). A general guideline is to set this to first page of the component that you are adding the Save As functionality to.

Here's what the example code looks like (from changeset:93)

GS_CI_UTILS_WRK.BCNAME = "GS_SAVEAS_TST0";
GS_CI_UTILS_WRK.RECNAME = "GS_SAVEAS_WRK0";
GS_CI_UTILS_WRK.PANELNAME = "GS_SAVEAS_TST0";

Create Component Specific Save As Page

In order to fill in the work record with the new key values, we need a page to display to the end-user. You can think of this page as being the functional equivalent of the "Add Mode" page that PeopleTools displays when you add a new value.

This page just needs to have the fields from the work record that was created in the previous step, plus the GS_CI_SAVE_AS_SBP subpage that is included in the App Designer project. You'll need to add this page to the component. That is the only customization to PeopleSoft delivered object that enabling Save As functionality requires.

Grant Security

You can grant security to use the Save As functionality to everyone that uses the component or limit it to a smaller group of users. This is done through standard PeopleSoft security configuration. It's considered good practice to grant the Save As functionality to anyone that has Add mode access to the component.

You will also need to grant access to the component interface as well for anyone that will be using the Save As functionality. If someone can get to the Save As page, but does not have access to the component interface, then the Save As processing will not work.

Create a page with the key fields in the work record that you created. Add the sub page GS_CI_SAVE_AS to this page. The subpage provides the push button that calls the appropriate PeopleCode functions and pops open a new window upon successful save. Add this page to the component. Grant security to the end user For accessing the Save As page in the component For accessing the Component Interface (the page won't work without this since it invokes the CI under the covers)

Once security has been set, then you're all ready to try it out.

Additional Edits

Edits on Save As Page

If you need additional control over the values used during the Save As process you can additional PeopleCode to the work record that you created.

You generally don't need to worry about this because the component's SearchEdit? and SearchSave? PeopleCode will run when the Save As logic is invoked.

The main exception to this rule is where one of the key fields has a prompt on it. The prompt validation will get invoked when the Save As logic calls the component interface, but the error message is not helpful; it tells the end-user that the value is invalid and to press F4 for a list of valid values. That error message goes back to the Windows client days for PeopleSoft and won't help someone figure out what the valid values are.

The way to avoid that is to set a prompt table edit on the work record. Be sure to not set it as a required field though so that it doesn't raise errors when someone is doing normal work that does not involve Save As logic.

Additional Logic After Copying New Values, but Before Saving

In some cases you may want to execute additional business logic after the new instance has been populated, but before the new instance has been saved.

To do that you'll want to create a separate "Save As" push button (since the one that is included with the ComponentInterfaceSaveAs project automatically saves things).

Your cloned version can then invoke your custom logic in between between the call to CICopy and the actual saving.

Attachments