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 Siebel 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 Siebel 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 Siebel 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

  1. Replace the primary_selector control with the autocomplete_control:

    1. Use an XML editor to open the forms_xx.xml file.

    2. 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.

    3. 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.

    4. Save, and then close the forms_xx.xml file.

    5. 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.

  2. Make the field that Siebel CRM Desktop uses with the autocomplete list a required field:

    1. Use a JavaScript editor to open the forms.js file.
    2. 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.

    3. 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:

  3. Disable the MVG button:

    1. 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;
      
    2. 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 Siebel 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.

    3. Save, and then close the forms.js file.

  4. Test your work:

    1. Log in to the client, and then navigate to the Account form.
    2. Create a new record.

    3. Attempt to save the record without entering a value in the Business Address field.

    4. Make sure Siebel CRM Desktop displays the dialog box informing you that you must enter a business address.

    5. Click in the Business Address field, and then make sure it displays the following:
      • the correct account (before the semicolon)

      • and the street address, city, state, postal code, and country (after the semicolon)

    6. Click the street address and make sure Siebel CRM Desktop displays the autocomplete list.

    7. Enter a few characters and make sure Siebel CRM Desktop modifies values in the autocomplete list so that they match the values you enter.

    8. Choose a value from the autocomplete list and make sure Siebel CRM Desktop sets the value in the field to the value you choose.