Updating One Field If the User Modifies Values In Another Field

You can configure Siebel CRM Desktop to update the value in one field if the user changes the value in another field. This functionality is known as on field update. The example in this topic configures Siebel CRM Desktop to do the following work:

  • If the name of the opportunity is Test, then set the Lead Quality to 5-Poor.

  • If the name of the opportunity is not Test, then set the Lead Quality to 3-High.

To update one field if the user modifies values in another field

  1. Add the following function:

    function on_name_changed()
    {
      var NameValue = ctx.form.item.snapshot['Name'];
      if (NameValue == "Test") ctx.form.lead_quality.value =     
          ctx.session.res_string("lang_lead_quality_poor");
      else
        ctx.form.lead_quality.value = 
          ctx.session.res_string("lang_lead_quality_high");
    }
    

    This on_name_changed function gets the value for the Name field from the snapshot. It then uses this value to set the value in the field that resides on the form to a value that the resource file contains. A snapshot is a function that allows Siebel CRM Desktop to get the current value of a field. For example, the following code gets the current value of the Name field:

    Ctx.form.item.snapshot['Name']
    

    For more information, see Customizing Form Functions.

  2. Call the function you added. You add the following event connector:

    ctx.events.connect(ctx.form["opportunity"],"on_focus_lost",on_name_changed);
    

    It is recommended that you use the on_focus_lost event handler for an edit control. If the opportunity field is a dropdown list, then it is more appropriate to use the changed event and to use the following code:

    ctx.events.connect(ctx.form["opportunity"],"changed",on_name_changed);
    

    For more information, see Customizing Event Connectors.

  3. Test your changes and then republish the customization package.

    For more information, see Republishing Customization Packages.