Sometimes in PeopleSoft you want to be able to vary the contents of a drop down list. For example you may want to only give the user the choice of selecting departments for a particular division.
You could do this by having a controlling field that is a high level key in the lookup table. PeopleSoft’s use of Set IDs utilises this method to restrict values based on their Set ID.
On occasion though, you may need to be able to dynamically change your values on the fly. For example you may have a radio button on a page that you use to control the values displayed in a drop down list. One way of doing this is to use %RECNAME_EDIT functionality.
In this technique you specify a field as the prompt then set its value in PeopleCode to the name of the table you want to use as your prompt table.
First off set the Prompt Table for the field you want to display values for to %fieldname where fieldname is the name of the field you are going to set in your PeopleCode. For example PeopleSoft often use %RECNAME_EDIT. RECNAME_EDIT is a field in the DERIVED table.
Second, add your edit field to the page or pages that contain your dropdown field making it display only and invisible. For example if you used a prompt of %RECNAME_EDIT you could add RECNAME from the DERIVED record to the page.
Finally add some PeopleCode to set the value of this field to the actual name of the prompt table.
e.g.
If (condition) Then
DERIVED.RECNAME_EDIT = "A_VIEW_VW";
Else
DERIVED.RECNAME_EDIT = "B_VIEW_VW";
End-If;
This can be done in Page PeopleCode, Component PeopleCode or FieldChange PeopleCode on a controlling field.
Thanks to Kevin Gavaghan for giving me a heads up on this technique a while back.
