I received a requirement to make the Anticipated Date field on the Payment Batch form mandatory for all users if the Payment Method field is Electronic. It seemed to be a very straight forward requirement whereby I only check the value of the Payment Method field and make the Anticipated Date field property, Required = True, by personalizing the form.
What I did not realize was the fact that this form is a folder form. Hence this personalization would have no effect if the form folder view did not show Anticipated Date field. Had there been a folder where the Anticipated Date field was viewable from the beginning then it would work. I had a very difficult time figuring out what to do as I could not force the users to make the Anticipated Date field viewable from Folder > Show Field > Anticipated Date
I hit upon another idea. Why not check whether the field Anticipated Date has a value whenever the control moves out from the record and the user tries to click on a button? If there was no value in the field I could raise an error message and stop the user from proceeding further. This worked out and I later on used this method for many other requirements.
To personalize the form,
Open the Payment Batch
Navigate to Help > Diagnostics > Custom Code > Personalize
Set the values
Trigger Event: WHEN-VALIDATE-RECORD
Trigger Object: BAT_SUM_FOLDER
Condition: :BAT_SUM_FOLDER.PAYMENT_METHOD != ‘Check’ AND :BAT_SUM_FOLDER.ANTICIPATED_VALUE_DATE IS NULL AND :BAT_SUM_FOLDER.CHECK_DATE > TO_DATE (’27-JUN-2011′, ‘DD-MON-YYYY’)
The condition for 27-Jul-2011 was kept as this personalization went live on 27-Jul-2011. This meant that any payment batch created before 27-Jul-2011 would not be affected.
Message Type: Error
Message Text: Please enter the Anticipated Value Date.
If this field is not shown on the form please make it viewable by going to the following path.
Path: Folder > Show Field > Anticipated Value Date
When we indicate to Oracle that an Error message is to be shown to the user, Oracle prevents further processing of data until the error has been rectified.
Now let us see the form in action.
Responsibility: Payables responsibility
Navigation: Payments > Entry > Payment Batches
|Create a payment batch|
Notice that when we create a payment batch the field, Anticipated Value Date, is non mandatory even though the Payment Method is set to Electronic.
Click on Save or Actions.
The popup message appears. This message appears every time an action is tried until the user populates Anticipated Date field.