Showing posts with label PeopleCode. Show all posts
Showing posts with label PeopleCode. Show all posts

Tuesday, 4 February 2014

DoSaveNow() saves and SetReEdit(True) nets the rebound

Recently I had a problem with DoSaveNow() not doing what it said on the tin and actually saving a component. Initially this was worked around by using CommitWork() instead, but ultimately this stopped working as well.

The solution was to use SetReEdit prior to doing the save. e.g.

SetReEdit(True);
DoSaveNow();

Set ReEdit switches re-edit mode on and off. When it is on, definitional edits (such as translate table and prompt table edits), as well as FieldEdit PeopleCode, are run on each editable field in the component when the component is saved.Whey the DoSaveNow failed to save without it and why it succeeded with it, I haven't got a Scooby's. But as it sorted out my save issue and stopped me swearing at the screen, I'm no complaining!

It only works.

Tuesday, 8 May 2007

How to Automatically Select Jobs on the Run Panel in PeopleSoft

To automatically select a job for running on the run panel in PeopleSoft add some PeopleCode to the RowInit event PRCSRQSTDLG_WRK.SELECT_FLAG to set this field.

e.g.

Evaluate %Component
When "COMPONENT_NAME_1"
SELECT_FLAG = "Y"
When "COMPONENT_NAME_2"
SELECT_FLAG = "N"
End-Evaluate;

How to use %RECNAME_EDIT as a Prompt Table

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.