Siebel CRM Desktop for IBM Notes 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
- Open Siebel Tools and then display the object type named Integration Object.
For more information, see Displaying Object Types in Siebel Tools.
- In the Object Explorer, click Integration Object.
- In the Integration Objects list, query the Name property for CRMDesktopOpportunityIO.
- In the Object Explorer, expand the Integration Object tree and then click Integration Component.
- In the Integration Components list, add a new integration component using values from the following table.
|
|
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.
- Deploy your changes to the Siebel Runtime Repository.
- Use an XML editor open the siebel_meta_info.xml file.
- Locate the following object:
TypeId="Opportunity"
- 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.
- Set the calculated field in Siebel CRM Desktop. You add the following code to the Ln_siebel_basic_mapping.xml file:
<field id="JVD Calculated"> <reader> <lotus_STD> <lotus_field id="JVDCalculated"/> <convertor> <string/> </convertor> </lotus_STD> </reader> <writer> <lotus_STD> <lotus_field id="JVDCalculated"/> <convertor> <string/> </convertor> </lotus_STD> </writer> </field>
- Open IBM Domino Designer, and then open the (SBL)form:opportunity form.
For more information, see Opening IBM Domino Designer.
- Use IBM Domino Designer to add and position the JVD Calculated field. Use the same Name for this field that you specified in the Ln_siebel_basic_mapping.xml file in Step 8.
In this example, name it JVDCalculated. Make sure that the Text and Editable properties are chosen for this field.
- Make the field read-only. In the Objects tab, choose the Input Enabled event, and then enter the following code in the pane that IBM Domino Designer displays on the right side of the workspace:
@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.
- Save your work.
- Open the SBL.Forms script library, and then add the following code to create a new class:
'=========================================================================== ' CallbackOpportunityJVDCalculate ' Class that represents '=========================================================================== Public Class CallbackOpportunityJVDCalculate As CallbackObject Private m_Doc As DocumentEx
'Comments for New Sub New(doc As DocumentEx) Set m_Doc = doc End Sub
'Comments for Invoke Public Function Invoke(params As DynamicArguments) Dim NameValue As String NameValue = m_Doc.SafeProperty("Name", "") m_Doc.Property("JVDCalculated") = NameValue & " - Calculated" End Function End Class
The Invoke function of this callback class gets the value of the Name field, and then writes this value to the JVDCalculated field plus the following string concatenated to the opportunity name:
- Calculated
To calculate the value, Siebel CRM uses the following code:
[Name] + " - Calculated"
- In the FormOpportunityEx class, switch to the PostOpen function, and then locate the following code:
Dim ControlStatus As New ControlEditable ("Status", Me.Form)
- Add the following code immediately after the code you located in Step 16:
Dim JVDCalculateCallBack As New CallbackOpportunityJVDCalculate (Me.DocumentEx) ControlName.OnChange.Connect JVDCalculateCallback
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.
- 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 LotusScript to Mimic Calculated Fields
You can write LotusScript that mimics the behavior of a calculated field. You can configure CRM Desktop to run this LotusScript 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.
|