Siebel CRM Desktop for Microsoft Outlook Administration Guide > Customizing Multi-Value Groups >
Making an MVG Field a Required Field
This topic describes how to make an MVG field a required field. The example in this topic describes how to make the Business Address field in the Account form a required field. It is recommended that you make an MVG field a read-only field only if necessary. Making an MVG field a read-only field might increase the effort required to replace a control at some future point, and also might add redundant code. You can make an MVG field a required field only with an autocomplete list. You cannot make an MVG field a required field with the mvg_primary_selector2 control. If CRM Desktop creates a new record, and if the MVG field is a required field in this record, then this field must contain an association before CRM Desktop can save the record. The mvg_primary_selector2 control requires that the user use the MVG dialog box to add this association, but CRM Desktop cannot display this dialog box until it saves the record, which it cannot do without the association. For more information about these controls, see Overview of Customizing Multi-Value Groups. To make an MVG field a required field
- Replace the primary_selector control with the autocomplete_control:
- Use an XML editor to open the forms_xx.xml file.
- Locate the following code:
<cell> <mvg_primary_selector2 id="business_address_mvg" tab_order="27"> <source type="Account.Business_Address.Association" left_id="AccountId" item_value="Business AddressId" display_format=":[:(Street Address):] :[:(City):], :[:(State):] :[:(Postal Code):] :[:(Country):]" /> <field>Primary Address Id</field> </mvg_primary_selector2> </cell>
This code renders the primary control.
- Replace the code you located in Step b with the code that renders an autocomplete list in the Business Address field.
For more information, see Code That Renders an Autocomplete List.
- Save, and then close the forms_xx.xml file.
- Use the following code to register the MVG:
register_mvg_dialog(ctx, "Business_Address", "sales_team_mvg", "btn_sales_team_mvg", { "use_autocomplete_list": true });
For more information, see Registering MVG Controls.
- Make the field that CRM Desktop uses with the autocomplete list a required field:
- Use a JavaScript editor to open the forms.js file.
- Locate the form handler for the form where you added the XML code in Step 1.
In this example you added the XML code in the Account form, so you must locate the form handler that the Account form uses.
- Modify the code you located in Step b to the following:
ctx.validator.validate_empty_field("Primary Address Id", "business_address_mvg","msg_account_business_address_validation");
where:
- Disable the MVG button:
- Add the following code to the end of the form handler function that you modified in Step 2:
ctx.form.[mvg_button_field_name].enabled = true;
- Locate the form_saved function, and then add the following code to this function:
ctx.form.btn_business_address_mvg.enabled = true;
The form_saved function resides in the form handler that you modified in Step 1. This configuration makes sure that CRM Desktop does not display the MVG dialog box before the it saves the object. It forces the user to enter characters in the field, and then to use the autocomplete list to choose an association.
- Save, and then close the forms.js file.
- Test your work:
- Log in to the client, and then navigate to the Account form.
- Create a new record.
- Attempt to save the record without entering a value in the Business Address field.
- Make sure CRM Desktop displays the dialog box informing you that you must enter a business address.
- Click in the Business Address field, and then make sure it displays the account to the left of the semicolon, and the street address, city, state, postal code, and country to the right of the semicolon.
- Click the street address and make sure CRM Desktop displays the autocomplete list.
- Enter a few characters and make sure CRM Desktop modifies values in the autocomplete list so that they match the values you enter.
- Choose a value from the autocomplete list and make sure CRM Desktop sets the value in the field to the value you choose.
Code That Renders an Autocomplete List
This topic describes the code that renders an autocomplete list. For more information about autocomplete lists, including the parent and child relationship that they use, see Registering Autocomplete Controls. The following code renders an autocomplete list: <autocomplete_list id="mvg_name" tab_order="tab_order"> <items format=":[:{child_Id@child_object_type/(:[:(child_fields):])}:]"> <source type="auto" name="search_string"/> <restriction>: <binary field="parent_field" condition="eq"> <value type="variable">id()</value> </binary> <binary field="child_field" condition="ne"> <value type="string">deleted</value> </binary> <suggestion format=":[:(autocomplete_source):]"> <source type="auto" name="autocomplete_source_object_type"/> </suggestion> </autocomplete_list>
where:
- mvg_name identifies the name of the MVG control.
- tab_order sets the position for the control that CRM Desktop makes active if the user presses the TAB key.
- child_Id identifies the object that contains the Id of the object that CRM Desktop displays to the right of the semicolon in the MVG field.
- child_object_type identifies the type of object that CRM Desktop displays to the right of the semicolon in the MVG field.
- child_fields identifies the fields that CRM Desktop displays to the right of the semicolon in the MVG field. You can use the following format to specify more than one field:
"[:(field_name):]:[:(field_name):]:[:(field_name):]"
CRM Desktop adds each field consecutively to the right of the semi-colon. For example, assume you specify the following:
(:[:(Street Address):] :[:(City):], :[:(State):] :[:(Postal Code):] :[:(Country):])
In this example, CRM Desktop displays Main Street: Los Angeles CA: 94865: USA. The character that occurs between the brackets specifies the separator. This example uses a colon:
]:[
- search_string includes the association that CRM Desktop uses to search in Outlook and in DB_FACADE. DB_FACADE is the native storage that CRM Desktop uses. It searches for an association object. An association object is a type of object that CRM Desktop defines in the siebel_basic_mapping.xml file.
- parent_field identifies the field that CRM Desktop uses as the source for the field that it displays to the left of the semicolon in the MVG field. CRM Desktop restricts the child fields that it displays to only fields that are children of the field that left_field identifies.
- child_field identifies the field that CRM Desktop uses as the source for the field that it displays to the right of the semicolon in the MVG field. CRM Desktop displays this field the first time it displays the MVG. If the user uses the autocomplete list to modify this field, then CRM Desktop sets right_field to the value that the user chooses.
- autocomplete_source identifies the fields that CRM Desktop uses as the source for the values that it displays in the autocomplete list. You can use the same format that child_fields uses to specify more than one field. To view an example autocomplete list, see Figure 19.
- autocomplete_source_object_type identifies the object type of the objects that autocomplete_source contains.
For example, the following code renders an autocomplete list in the Business Address field: <autocomplete_list id="business_address_mvg" tab_order="27"> <items format=":[:{Business AddressId@Business_Address/(:[:(Street Address):] :[:(City):], :[:(State):] :[:(Postal Code):] :[:(Country):])}"> <source type="auto" name="Account.Business_Address.Association"/> <restriction> <binary field="Business AddressId" condition="eq"> <value type="variable">id()</value> </binary> <binary field="Status" condition="ne"> <value type="string">deleted</value> </binary> </restriction> </items> <suggestion format=":[:(Street Address):] :[:(City):], :[:(State):] :[:(Postal Code):] :[:(Country):]"> <source type="auto" name="Business_Address"/> </suggestion> </autocomplete_list>
|