This page describes the process of setting default values in an application form window. Default values can be produced both in the client and server frameworks. This functionality is used to put default values in new records. The main reason for doing that is to improve usability by adding data that can be predicted during client development.
Note: Keep in mind that the same server logic can be used from different clients. That means that if you generate well defined default values in the server logic all clients using the same LU will act the same giving a consistent and good usability. For default values that are client specific the values shall be set in the client.
Just before the server prepare method is called the framework is calling the
virtual method vrtDataRecordGetDefaults
. This method shall be
overridden in order to set default values in the client logic.
public override SalBoolean vrtDataRecordGetDefaults() { using (new SalContext(this)) { if (sCountryId != Ifs.Fnd.ApplicationForms.Const.strNULL) { Sal.SendMsg(colsCountryId, Ifs.Fnd.ApplicationForms.Const.PM_DataItemValueSet, 1, sCountryId.ToHandle()); } return true; } }
Figure 1: Overrides vrtDataRecordGetDefaults
to
provide default value for field colsCountryId
.
When a new record is to be created (i.e. when the user presses new,
duplicate or pastes a record to a form or a table) the framework will
prepare the record by calling the server method NEW__
with the action
PREPARE
. In the server logic the default values can be added to the attribute string
by using the Client_SYS.Add_To_Attr
procedure. Then the attribute string is returned to the client
where the values are put on the created record.
Client_SYS.Add_To_Attr('PET_TYPE', 'Penguin', attr_);
Figure 2: Example of adding a value to an attribute string in server PL/SQL logic.
Before the server is called the framework will call the virtual
vrtDataRecordGetDefaults
method described in
Default values from client logic.
This method can be used to provide the server logic with directives as the attr_
parameter that is used when calling the server is first initiated with values
for all the client fields that are currently edited. In Figure 2 the added value
could have been conditionally added depending of a value from the client.
If there is no server default values to get from the server or if custom
client logic should completely replace any server values there is a way to increase
performance by suppressing the preparation call to the server. This is done by
overriding the virtual method vrtDataRecordPrepareNew
public override SalBoolean vrtDataRecordPrepareNew() { return true; }
Figure 3: Override vrtDataRecordPrepareNew
to suppress
the server record preparation