Adding Custom Logic

This task is a step in Process of Adding Custom Objects.

To improve usability, sometimes you must add custom logic to Siebel CRM Desktop that allows the user to manipulate Outlook data. For example:

  • Automatically include the current user Id in the Owner field.

  • Cause the first letter of each word in the description of an activity to automatically capitalize.

  • Change the state of some controls. For example, to inform the user that the control is required.

Siebel CRM Desktop uses JavaScriptto customize Outlook data. It runs this JavaScript on events, so you define the events that are involved and you specify the code that this script calls when an event occurs. To do this, you add the following attributes to the form tag:

<form id="SBL Activity" on_open="form_open()" on_saving="form_saving()">

Siebel CRM Desktop does the following work:

  • If the user opens the form, then it calls the form_open function.

  • If the user saves the form, then it calls the form_saving function.

You define these functions in the forms_12.xml file. For more information, see Correct Usage of the Forms File and Object ID.

To add custom logic

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

    For more information, see Files That the Customization Package Contains.

  2. Add the custom logic for this example. You add the following code:

    <form id="SBL Activity"on_open="form_open()" on_saving="form_saving()"">
      <validation_rules>
        (……………..)
      </validation_rules>
      <script>
        <![CDATA[
        function form_open()
        {
          //this makes a border for these controls to inform users that 
          //these fields are required
          form.Type.required = true;
          form["0x20017"].required = true;
    
          //this code pre-fill Owner field by Current user Id
          var defaults = find_item("::Defaults", create_criteria("or"));
          if (form.item.snapshot["Primary Owner Id"] != null)
            form.item["Primary Owner Id"] = defaults.CurrentUser;
        }
        function form_saving()
        {
          //this makes all first letters capitalized
          var fields = form.item.snapshot;
          form.item.Description = fields. Description.replace(/\b[a-z]/
    g,function(w){return w.toUpperCase()});
        }
        ]]>
      </script>
    

For more information, see Customizing Form Functions.