Siebel CRM Desktop for Microsoft Outlook Administration Guide > Customizing Siebel CRM Desktop > Customizing Field Behavior >

Creating Calculated Fields


You can configure Siebel CRM Desktop to display a calculated field in the client so that it behaves in a way that is similar to how a calculated field behaves in the client of a Siebel Business Application. The example in this topic configures a calculated field in the client. If the user changes the opportunity name, then the value in this field also changes. You do the following:

  • Expose a calculated field to an integration object and synchronize it with CRM Desktop. This configuration allows CRM Desktop to get a correct starting value for the calculated field. In this example, you use a calculated field named JVD Calculated. It includes the following calculated value:

    [Name] + " - Calculated"

  • Use a CRM Desktop calculated field to make a working copy of the original calculated field. You do this because you cannot configure CRM Desktop to make changes to a calculated field from Siebel CRM while the user is using CRM Desktop. Doing so might cause a synchronization error.
  • Use JavaScript in the form to make sure the copy of the calculated field changes if the user changes the opportunity name. This configuration allows you to use the same behavior that occurs in the client of a Siebel Business Application for the calculated field.

For more information about each of these items, see Alternative Ways to Create Calculated Fields.

To create a calculated field

  1. Open Siebel Tools and then display the object type named Integration Object.

    For more information, see Displaying Object Types in Siebel Tools.

  2. In the Object Explorer, click Integration Object.
  3. In the Integration Objects list, query the Name property for CRMDesktopOpportunityIO.
  4. In the Object Explorer, expand the Integration Object tree and then click Integration Component.
  5. In the Integration Components list, add a new integration component using values from the following table.
    Property
    Value

    Name

    JVD Calculated

    Data Type

    DTYPE_TEXT

    Length

    285

    External Sequence

    240

    External Name

    JVD Calculated

    External Data Type

    DTYPE_TEXT

    XML Sequence

    240

    XML Tag

    JVDCalculated

    This integration component exposes the Siebel CRM calculated field to the integration object for the opportunity.

  6. Deploy your changes to the Siebel Runtime Repository.
  7. Use an XML editor open the siebel_meta_info.xml file.
  8. Locate the following object:

    TypeId="Opportunity"

  9. Add the following code to the object you located in Step 8:

    <field Name='JVD Calculated' Label='JVD Calculated' DataType='DTYPE_TEXT' IsFilterable='no' IsHidden='no'IOElemName='JVDCalculated' />

    This code adds the JVD Calculated field to the metadata object for Opportunity. For more information, see JavaScript Files in the Customization Package.

  10. Set the calculated field in Siebel CRM Desktop. You add the following code to the siebel_basic_mapping.xml file:

    <field id="JVD Calculated">
        <reader>
          <mapi_user>
            <user_field id="sbl JVD Calculated" ol_field_type="1"></  
              user_field>
            <convertor>
              <string/>
            </convertor>
          </mapi_user>
      </reader>
      <writer>
        <Outlook_user>
          <user_field id="sbl JVD Calculated" ol_field_type="1"></user_field>
          <convertor>
            <string/>
          </convertor>
        </Outlook_user>
      </writer>
    </field>

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

    For more information about the forms_xx.xml file, see Files in the Customization Package.

  12. Locate the Opportunity form. You locate the following code:

    <form id="SBL Opportunity">

  13. Add the calculated field to the opportunity form. You add the following code to Opportunity form:

    <edit id="jvd_calculated">
      <field value="string">JVD Calculated</field>
    </edit>

  14. Use a JavaScript editor to open the forms.js file.
  15. Make the field read-only. You add the following code to the opportunity_form function:

    ctx.form.jvd_calculated.enabled = false;

    A calculated field in Siebel CRM is read-only. It is recommended that you also make the calculated field in CRM Desktop read-only. For more information, see Making Fields Read-Only.

  16. Save your work.
  17. Configure CRM Desktop to update the field value. You add the following code to the file:

    function jvd_calculate()
    {
      var NameValue = ctx.form.item.snapshot['Name'];
      ctx.form.jvd_calculated.value = NameValue + " -
    Calculated";
    }

    This function gets the value of the Name field. It then writes to the jvd_calculated field the value of this Name field plus the following string concatenated to the opportunity name:

    - Calculated

    To calculate the value, Siebel CRM uses the following code:

    [Name] + " - Calculated"

    For more information, see Customizing Form Functions.

  18. Add the following code to the on_focus_lost event:

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

    For more information, see Customizing Event Connectors.

    This code makes sure CRM Desktop calls this function if the user changes the value in a field that the calculation uses. In this example, the calculated value depends only on the opportunity name, so this code only calls this function if the user changes the value in the Opportunity Name field.

    This code creates a dependency between an event and a function. If the form field is:

    • A dropdown list, then you use the changed event.
    • An edit box, then you use the on_focus_lost event.

      The opportunity name field is an edit box so you configure CRM Desktop to call the function on the on_focus_lost event.

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

    For more information, see Republishing Customization Packages.

Alternative Ways to Create Calculated Fields

This topic describes alternative ways to create a calculated field.

Exposing Calculated Siebel CRM Fields

To create a calculated field, you can expose a calculated field that exists in Siebel CRM to an integration object and then synchronize it to Siebel CRM Desktop. However, if this field is not read-only in the client, then CRM Desktop attempts to synchronize the new value back to Siebel CRM, and this synchronization fails.

Specifying Fields in the Siebel Meta Info File as Calculated Fields

You can specify a field in the siebel_meta_info.xml file as a calculated field. To do this, you set the IsCalculated attribute to yes and then use the following code to specify a value for the Formula attribute:

:[ :] Block, should contain field.
:( ) Container for fieldname.

For example, you can use the following code to combine the First Name field and the Last Name fields:

:[:(First Name) :(Last Name):]

This primary allows you to concatenate fields with the possibility to add some static characters to the concatenation. It does not allow you to configure CRM Desktop to do a calculation. You specify this code in the siebel_meta_info.xml file. CRM Desktop only determines the calculated value during synchronization. From this point the field is read-only.

Using JavaScript to Mimic Calculated Fields

You can write JavaScript that mimics the behavior of a calculated field. You can configure CRM Desktop to run this JavaScript code only in reply to something that happens in the form, such as the user changing the value in a field. This configuration updates a field if the data changes in the form but you cannot use it to control the value of a calculated field that Siebel CRM Desktop displays when the user opens a form.

Siebel CRM Desktop for Microsoft Outlook Administration Guide Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.