UK Oracle User Group


Checkbox with Error

28 August 2015

We've spotted a new feature on Graham Smith's blog you might find useful. Don't forget to leave feedback for Graham.

This is the first in what I hope to be a regular Friday feature on PeopleCode.  I hope you find these useful.


Today's puzzle came from a friend of mine David Jubber at BMI Healthcare - thanks David !

QUESTION:  What happens if you tick ON a check box but during the FieldEdit event an ERROR is thrown?
 
OPTIONS:  Would you expect it to display the error message and...
 
   (A) leave the check box ticked ON, or
   (B) leave the check box unticked

Figure 1 shows the PeopleCode behind the check box and I'm simply throwing an Error if the user is gsmith.
Fig 1. Code to validate the change of CheckBox
 
 
Fig 2. Error Message after check box ticked ON


ANSWER:  The answer is OPTION (A).  The tick is left ON even though the Edit (validation) fails the Edit test.

 
Is this what you were expecting?  It might not behave quite as you wanted.  After all ... the edit failed.... so clearly I shouldn't be allowed to tick the check box on.  So, let's try and code around this behaviour and undo the tick action with what seems like some obvious PeopleCode.  See Fig 3.
 
Fig 3.  Code to revert the tick action

However, as you can see from Fig. 4 it's not possible to make change to the current field in FieldEdit.  (you can read more onprocessing sequence in PeopleBooks ). 

Fig 4.  Illegal operation to set current field value during FieldEdit

Workarounds

One possible solution might be to move the code from FieldEdit to FieldChange, use a MessageBox function instead of ERROR and handle the "exit error" from the event manually.   FieldChange allows the setting of current field and can therefore reset the checkbox value to OFF.

Interestingly, Radio Buttons do not behave the same.  This next example uses the same field and the same code but the radio button change is reset to it's original value if the Edit fails.
 
Fig 5. Radio buttons behave as OPTION (B)
  • Which one do you prefer?  
  • I wonder why they behave differently?  
  • Can anyone suggest another solution to revert the check box on ERROR?
  • Why doesn't the checkbox get highlighted red?
NOTE: I'm not responsible for the label typo on field object PTCHKBX.  That's a delivered PeopleTools object.  :-)
 
 

We'd love to get your feedback on this; you'll need a UKOUG login to provide it, so if you don't have one, please click on 'create a web profile' first.

Send this page to your friend

Your details

Your friend's details

Submit

Top