Fri 9 Dec 2005
If you’re a PeopleSoft programmer, the Error() function is probably one of the first function you learned in PeopleCode. Raising an error — via the Error or MessageBox functions — is an indispensable operation, and serves multiple purposes throughout the component processor flow. Aside from displaying a message to the user, issuing an error has an accompanying effect which depends on which PeopleCode event it occurs. In FieldEdit, it highlights the affected field and stops further processing; in SaveEdit, it is used to abort save processing (SavePreChange–Workflow–SavePostChange); in RowDelete, it is used to cancel the user delete action.
However, you might come across a situation where you want the effect associated with an error, but displaying a message is not desired (as this chap experienced the need to abort save processing without displaying a message).
The user with the problem did not explain his specific situation. Pondering over this, I think a situation where I would find this necessary is when the requirement calls for displaying a modal page when user clicks on save or deletes a row. The modal page might contain data populated to a grid or other complex information that user needs to review in order to decide whether to proceed with the save or delete. The modal page would contain an Ok and Cancel button; when user clicks Cancel, this should abort the save/delete processing. Because of the complex nature of the information being displayed, issuing a warning is out of the question. Following is how the PeopleCode would look like:
[SaveEdit or RowDelete]
If DoModal(Page.REVIEW_INFO, "Confirm Operation", -1, -1) = 0 Then
Error "Save/delete canceled.";
End-If;
Now for the user, when he clicks on the Save/Delete button, a fancy page will be presented to him for review. When he clicks on Ok, then the operation is processed. However, when he clicks Cancel, he will receive another message informing him that the operation is canceled — which is pretty much an undesired effect which will likely be frowned upon by the user.
Now, in PIA the error messages are displayed to the user via javascript alert commands appended to the body’s onload handler. By inserting a snippet of javascript to the page via an HTML area, we should be able to override the behavior of the alert function before the messages are actually displayed. The following script checks for a distinct string on message being displayed — in (dis)honor of Sony’s notorious rootkit, LOL — we could assign the string $sys$NoEcho:
<script type="text/javascript">
var oldalert = window.alert;
window.alert = function() {
var param = arguments[0];
if (param.indexOf("$sys$NoEcho") == -1) oldalert(param);
}
</script>
After this script is evaluated, the alert function now checks any messages passed to it: if it contains the magic string $sys$NoEcho it will not be displayed. Important note: Make sure to place the HTML area on level 0 of the primary page.
Now the PeopleCode should be modified to include the magic string in the message:
If DoModal(Page.REVIEW_INFO, "Confirm Operation", -1, -1) = 0 Then
Error "$sys$NoEcho: Save/delete canceled.";
End-If;
December 23rd, 2005 at 12:28 am
Hi,
We r using Peopletools 8.21, I’ve tried using the code,but, the peoplecode is not accepting the $sys$NoEcho in the error statement…Its showing as Unmatched quote.(2,3), highlighting the string.
Is their any way we have to define the string before calling it in the program.
Please let me know.
Thanks,
Hruday
December 23rd, 2005 at 12:58 am
Vijay/Hruday,
Do not copy & paste the code from above verbatim. This is because my blogging engine is replacing the double-quotes with another character (I have yet to fix this). Just make sure all double-quote characters in your PeopleCode are in fact double-quotes. Delete those characters and manually press the double-quote key.
Joe
December 23rd, 2005 at 8:41 am
Update: I’ve fixed the double-quotes in the code samples above.
June 23rd, 2006 at 11:39 pm
Pondering this code, I’m trying to figure out a way to do Error processing on SaveEdit without stopping processing (so that all invalid values are determined - not just one) but page is not Saved. Cannot used FieldEdit, because that would do only 1 at a time, and cause massive errors when using a page functionality to mass copy a value to all rows. What I am trying to do is highlight (in red “PSERROR” style) all values that do not meet a defined criteria on the page. There can be hundreds of rows - they need to be able to see at one time. Any ideas???
Thanks,
Lorelei
March 29th, 2007 at 7:44 am
Good Article…appreciate it.
The place where I am working now seems to have turned off all save warnings in PS v 8.8. So when I leave job data and forget to click the save button, there is no warning. I checked and my user preference has the display warnings checked, and my security is not set to super user. Any ideas?? This happens for everyone here.
March 30th, 2007 at 8:07 am
Blake,
1) Go to PeopleTools > Personalization > Personalization Options
2) Choose Category Level “PeopleTools”
3) Check the value of SWARN
Hope that helps.
March 30th, 2007 at 9:34 am
Hey Chillijoe
Got your message…tried it out…still have the same issue…I’m thinking it’s a setting on a webserver or something…I checked with I/T again today…they’re lost…I’ll let you know if we ever find it.
thanks again
blake