Customizing Defaulting
Defaulting is a type of form function that automatically enters a value in the field of a form when the user creates a new item. It gets the functions and values for these fields from the business_logic.js file that defines the object, and then uses these functions and values to enter the field values. Defaulting uses the following code:
ctx.form_links_manager.init_new()
This code exists in every form handler. It calls the init_new method
that resides in the form_links_manager, which is an object that determines
the behavior of a form and specifies the relationship that exists
between controls that reside in this form and the fields that these
controls reference. The init_new method gets information about an
object from the business_logic.js file, including information about
how the defaulting options are set for the object. You specify these
options in the //Defaulting
section of the business_logic.js
file. For more information about adding default values, see Adding Default Values to Fields.
To customize defaulting
Use a JavaScript editor to open the forms.js file.
Locate the following section:
//Defaulting
Add the defaulting that your customization requires to the section that you located.
You use the following format to define defaulting:
scheme.objects.get_object(object_type).get_field(object_field)["source"] = "string_value";
where:
object_type identifies the type of object where Siebel CRM Desktop must enter a default value. For example, to add a default value for an action.
object_field identifies the name of a field where Siebel CRM Desktop must enter a default value. This field resides in the object type, such as Status.
source identifies how Siebel CRM Desktop gets the default value that it enters.
string_value identifies where Siebel CRM Desktop gets the string that it uses for the default value.
The following table describes how you set string_value depending on how you set source.
Source | Description |
---|---|
initial_value |
Siebel CRM Desktop gets the default value from a string that you define. You use the following format:
For example:
|
initial_value_res |
Siebel CRM Desktop gets the default value from a string key that the business_logic.js file or the package_res.xml file contains. You use the following format:
For example, the following code enters a value in the Status field of an action. It uses the lang_action_initial_status string key from the package_res.xml file to get this value:
where:
This tag sets the value of the string to Active. |
initial_value_fn |
Siebel CRM Desktop gets the default value from a function. This function resides in the business_logic.js file. You can use initial_value_fn if you use custom logic to determine the default value. You use the following format:
The following example enters a default value in the Percent Complete field of an action. It calls the percent_f function that resides in the business_logic.js file to get this value. The percent_f function calculates and then returns the default value:
|
initial_links_fn |
Siebel CRM Desktop gets the default value from a function. You can use initial_links_fn if the user must create a link between objects. initial_links_fn is similar to initial_value_fn except the function must return an array instead of a string. This array must include one or two objects, depending on the types of links that you require Siebel CRM Desktop to create. The following example adds a new link anytime Siebel CRM Desktop creates a new action:
|