Registering Autocomplete Controls
This topic describes how to register an autocomplete control. Note the following:
An autocomplete control is a type of control that displays a many-to-one relationship between the current object type and another object type. For example, between many opportunities and an account. It automatically displays objects in a drop-down list while the user enters characters in a field. For example, if the user enters the letters
Big
in the Account field of the Opportunity form, then Siebel CRM Desktop displays account names that start withBig
, arranged in ascending alphabetic order. The user can then choose an account from this list.An autocomplete list is a type of drop-down list that displays a many-to-many relationship between the current object type and another object type. For example, between parent opportunities and child contacts. It automatically displays child objects in a drop-down list while the user enters characters in a field. For example, if the user enters the letters
Doe
in the Contact field of the Opportunity form, then CRM Desktop displays a drop-down list that includes contact names that start with Doe, arranged in ascending alphabetic order. The user can then choose a contact from this list.
To view an example that registers an autocomplete control, see Modifying the Business Logic and Testing Your Work, and Defining the View. For an alternative to using an autocomplete control, see Configuring Autocomplete Lists and Primary Selectors for MVGs.
To register autocomplete controls
Use a JavaScript editor to open the forms.js file.
Locate the form handler you must modify.
For more information, see Customizing Form Handlers.
Add the following code to the form handler you located:
register_autocomplete_control(ctx, object_type, autocomplete_control, salesbook_button, options)
where:
ctx
is a default parameter. You do not modify this parameter.object_type identifies the object type that Siebel CRM Desktop displays in the autocomplete control and in the SalesBook control.
autocomplete_control specifies the name of the autocomplete control that the form uses. The forms_xx.xml file defines this name.
salesbook_button specifies the name of the button control that the user clicks to open the SalesBook control.
options allows you to specify more options. For more information, see Registering Autocomplete Controls.
For example:
register_autocomplete_control(ctx, "Account", "account_id", "btn_account_select", { "online_sb": new mvg_dialogs.online_sales_book() });
This code does the following work:
Displays accounts in the autocomplete control
Uses
account_id
as the name of the autocomplete control that the form usesDisplays the
btn_account_select
button that the user clicks to open the SalesBook controlUses options to specify other information.
Including Options When Registering Autocomplete Controls
You can include the following options when you register an autocomplete control:
online_sb. Displays the Online button in the SalesBook control.
sources. Defines options for an object that resides in the business_logic.js file.
You use the following format to add these options:
var custom_options =
{"option":value,"option":value}
where:
Curly brackets enclose the options.
A colon separates each option.
Double quotation marks (") enclose each key.
Values can reside in the form that a JavaScript object uses or in a JavaScript array.
For example, assume you specified to use the accounts:salesbook view in the SalesBook for an account. You specified this configuration in the options for the selector. Assume you must now configure Siebel CRM Desktop to use a custom SalesBook control for the account object. To do this, you can use the following code:
var account_options =
{
"online_sb": new mvg_dialogs.online_sales_book(),
"sources":[
{
"caption": "obj_account_plural_1",
"view_id": "accounts:salesbook",
"search_by": ["Name"],
"allow_new": false,
"online": {
"view_id": "accounts:online_salesbook",
"like_template": "*{keyword}*",
"filter_fn": function(ctx, keywords_filter) { return keywords_filter; }
}
}
]
}
where:
account_options
online_sb
is the first option. The following value is predefined. You must not modify it:new mvg_dialogs.online_sales_book()
sources
is the second option. You must specify the values for this option as a JavaScript array that includes the settings for the JavaScript object, such ascaption
andview_id
.