Tuesday, 15 April 2014

Invoke the calendar for entering dates on a custom form

For data block items which have a data type as DATE it is better to restrict the user’s entry so that there is no chance of wrong data type entry and hence no chance of an error. If we connect the Oracle provided CALENDAR block to the item the users will find this to be very user friendly as well.

To add the Calendar, identify the DATE item on the datablock.

We have identified the field, DATE_BLKLIST, to invoke the calendar. Let us check the properties of the item. Double click on the item to show the properties.
Check the data properties. Notice that there is no Format Mask set. I prefer to set this format mask so that the date format appears as per my choice. I will set it to DD-MON-YYYY.


Close the properties screen.
We want the Calendar to be displayed to the user when the user clicks on this field, i.e. DATE_BLKLIST
Now add a trigger, WHEN-MOUSE-CLICK, on this item.
Add the following code in the trigger,
The item will look like this,
Make other changes on the form as per your requirement. Save the form and compile it on the server.
Test the changes
Open the form in Oracle Apps, Create a new record, Click on the field, Date Blklist.

The calendar is now displayed. Select a date on the calendar and press OK button.
Notice that the date format is set to DD-MON-YYYY, i.e. as per the format mask set. Now save the record.
Check the record in the database with the following query
1
2
3
SELECT *
  FROM xx_supplier_blacklist
 WHERE blacklist_id = 4