Setting Default Values

This topic describes the values that you can use to specify the source of the default value. You specify this value in the default_source variable of the create_siebel_meta_scheme2 function.

Setting Fixed Default Values

To set a fixed value, you set the default_source variable of the create_siebel_meta_scheme2 function to the following value:

initial_value

You typically use this format with a number that does not require a translation, such as a Boolean number or an empty string where the default value is empty. You use the following format:

scheme.objects.get_object("object_type").get_field("field_name")[“initial_value"] = value;

Example 1

To set the Appt PIM Flag field that resides in the Action object, you use the following code:

scheme.objects.get_object("Action").get_field("Appt PIM Flag")["initial_value"] = true;

This example sets the default value to true. It does not use a list of values. The Appt PIM Flag field is a Boolean field.

Example 2

To set the country code for the phone number to a default value when the user creates a new account, you can use the following code:

scheme.objects.get_object("Account").get_field("MainPhone Number")["initial_value"] = "+31";

Setting Default Values That Are Language Dependent

To get a language dependent value from the resource file, you set the default_source variable of the create_siebel_meta_scheme2 function to the following value:

initial_value_res

This value uses the value that Siebel CRM Desktop defines in the package_res.xml file and in each language-specific package_res_XX_yy.xml file. It allows you to use a different default value for each language. If the MLOVs (multi-value lists of values) are correctly configured on the Siebel Server, then Siebel CRM Desktop stores the correct Language-Independent Code on the server. You use the following format:

scheme.objects.get_object("object_type").get_field("field_name")["initial_value_res"] = resource_key;

Example

The following example specifies to set the default value of the Display field that resides in the Action object to the value that the lang_action_display_activities_only resource key contains:

scheme.objects.get_object("Action").get_field("Display")["initial_value_res"] = "lang_action_display_activities_only";

The following values in the resource file determine the default value:

  • The English resource file includes the following code:

    <str key="lang_action_display_activities_only">Activities Only</str>

    At run time Siebel CRM Desktop sets the default value in the English client to Activities Only.

  • The Dutch resource file includes the following code:

    <str key="lang_action_display_activities_only">Alleen activiteiten</str>

    At run time Siebel CRM Desktop sets the default value in the Dutch client to Alleen activiteiten.

Setting Default Values for Functions

To set the default value for a function, you set the default_source variable of thecreate_siebel_meta_scheme2function to the following value:

initial_value_fn

This value uses a function that returns a value. It allows you to do more complex lookups. You use the following format:

scheme.objects.get_object("object_type").get_field("field_name")["initial_value_fn"] = function_name;

Example

The following example comes predefined with Siebel CRM Desktop. It calls the following get_default_currency_code function to determine the currency code that Siebel CRM Desktop sets for the account:

scheme.objects.get_object("Account").get_field("Currency Code")["initial_value_fn"] = get_default_currency_code;

The following predefined code defines the get_default_currency_code function. You can also write your own function that provides a default value:

function get_default_currency_code(ctx)
{
  var defaults = helpers.get_defaults(ctx.session);
  var currency_id = null;
  if ((defaults != null) && (defaults["CurrencySymbol"] != null))
{
  var currency = ctx.session.open_item(defaults["CurrencySymbol"]);
    if (currency != null)
    {
    currency_id = currency.id();
    }
  }
return currency_id;
}

Setting Default Values For Links

To set the default links that Siebel CRM Desktop uses for an object type, you set the InitialLinksCallback property of the descriptor that this object type uses to an instance of the class that Siebel CRM Desktop gets from the CallbackObject class. Siebel CRM Desktop uses this property to create the initial links. The following example uses a multi-value group that returns multiple records:

scheme.objects.get_object("Account")["initial_links_fn"] = prefill_team;

This example uses a multi-value group that associates multiple records. To add multiple team members instead of setting a single value, you can use a function that you specify elsewhere and use the following source:

initial_links_fn

Setting Default Values That Are Language Dependent

To get a language dependent value from the resource file, you set the default_source variable of the create_siebel_meta_scheme2 function to the following value:

initial_value_res

This value uses the value that Siebel CRM Desktop defines in the package_res.xml file and in each language-specific package_res_XX_yy.xml file. It allows you to use a different default value for each language. If the MLOVs (multi-value lists of values) are correctly configured on the Siebel Server, then Siebel CRM Desktop stores the correct Language-Independent Code on the server. You use the following format:

scheme.objects.get_object("object_type").get_field("field_name")["initial_value_res"] = resource_key;

Example

The following example specifies to set the default value of the Display field that resides in the Action object to the value that the lang_action_display_activities_only resource key contains:

scheme.objects.get_object("Action").get_field("Display")["initial_value_res"] = "lang_action_display_activities_only";

The following values in the resource file determine the default value:

  • The English resource file includes the following code:

    <str key="lang_action_display_activities_only">Activities Only</str>

    At run time Siebel CRM Desktop sets the default value in the English client to Activities Only.

  • The Dutch resource file includes the following code:

    <str key="lang_action_display_activities_only">Alleen activiteiten</str>

    At run time Siebel CRM Desktop sets the default value in the Dutch client to Alleen activiteiten.

Setting Default Values for Functions

To set the default value for a function, you set the default_source variable of thecreate_siebel_meta_scheme2function to the following value:

initial_value_fn

This value uses a function that returns a value. It allows you to do more complex lookups. You use the following format:

scheme.objects.get_object("object_type").get_field("field_name")["initial_value_fn"] = function_name;

Example

The following example comes predefined with Siebel CRM Desktop. It calls the following get_default_currency_code function to determine the currency code that Siebel CRM Desktop sets for the account:

scheme.objects.get_object("Account").get_field("Currency Code")["initial_value_fn"] = get_default_currency_code;

The following predefined code defines the get_default_currency_code function. You can also write your own function that provides a default value:

function get_default_currency_code(ctx)
{
  var defaults = helpers.get_defaults(ctx.session);
  var currency_id = null;
  if ((defaults != null) && (defaults["CurrencySymbol"] != null))
{
  var currency = ctx.session.open_item(defaults["CurrencySymbol"]);
    if (currency != null)
    {
    currency_id = currency.id();
    }
  }
return currency_id;
}

Setting Default Values For Links

To set the default links that Siebel CRM Desktop uses for an object type, you set the InitialLinksCallback property of the descriptor that this object type uses to an instance of the class that Siebel CRM Desktop gets from the CallbackObject class. Siebel CRM Desktop uses this property to create the initial links. The following example uses a multi-value group that returns multiple records:

scheme.objects.get_object("Account")["initial_links_fn"] = prefill_team;

This example uses a multi-value group that associates multiple records. To add multiple team members instead of setting a single value, you can use a function that you specify elsewhere and use the following source:

initial_links_fn