Siebel Object Interfaces Reference > About Object Interfaces and the Programming Environment > Siebel Object Interface Methods That You Can Use to Control Data and Objects >

Methods That Access Data from Business Components


This topic describes the object interface methods that allow your configuration to access and modify data that resides in a Siebel application. A business component can provide data for each field of each business component record, such as the fields of an opportunity. You can use a business component to read data, manipulate data, and then write this data to the Siebel database.

You can use a custom script that you write in Siebel VB or Siebel eScript. For example, if you create a script in Siebel VB or Siebel eScript that references the NewRecord event in a business component, then Siebel CRM calls this script. This situation is true if any of the following items calls the event:

  • The NewRecord method
  • Another Siebel VB or Siebel eScript script
  • A Siebel object interface

An event is available only with Siebel VB or Siebel eScript.

Adding and Inserting Records

You can use Siebel VB or Siebel eScript to mimic one of the following commands in the context of a many-to-many relationship:

  • Add New Record. Associates a new child record.
  • Insert Record. Creates a new record in the child business component.

You can use one of the following methods to associate a new child record:

  • GetAssocBusComp
  • Associate

You can use one of the following methods to create a new record in the child record:

  • The NewRecord method in a child business component
  • The GetMVGBusComp method and the NewRecord method

How Siebel CRM Saves a Record to the Siebel Database

Siebel CRM saves a record to the Siebel database in the following situations:

  • Explicitly by using the BusComp.WriteRecord method.
  • Navigating away from the current record by any of the following object interface methods:
    • BusComp.Associate.
    • BusComp.DeleteRecord. It moves the cursor to another record, so this method automatically saves the record.
    • BusComp.FirstRecord.
    • BusComp.LastRecord.
    • BusComp.NextRecord.
    • BusComp.PreviousRecord.
  • Closing a business component by setting the BusComp method to Nothing.

Example of Accessing Data from an Existing Business Component Instance

If Siebel CRM starts an event, then the code in this example calls an object interface method that resides on an existing business component instance. The term instance describes the current, run-time state of an object. For example, a business component instance is a run-time occurrence of a business component. It includes all of the run-time data that the business component currently contains, such as the values for all business component fields and the values for all properties of this business component. For example, an instance of the Contact business component includes the current, run-time value of the City field that resides in this business component, such as San Francisco. You can configure Siebel CRM to get a business component instance, and then modify this data or call the methods that this business component references.

In the following example, the VB script resides in the SetFieldValue event of the business component:

Sub BusComp_SetFieldValue (FieldName As String)
Dim desc As String
Dim newDesc As String

TheApplication.TraceOn "c:\temp\trace.txt", "Allocation", "All"
If FieldName = "Type" Then

   newDesc = "Any valid string that contains the new description."
   desc = Me.GetFieldValue("Description")
   TheApplication.Trace "The previous description is " & desc
   Me.SetFieldValue "Description", newDesc
   TheApplication.Trace "The new description is " & newDesc

End If
TheApplication.TraceOff

End Sub

Example of Accessing Data from a New Business Component Instance

The example in this topic describes how to create a new business object instance and a business component instance. It uses the PreSetFieldValue event of the Opportunity business component. If the user updates the Sales Stage to 07 - Verbal Agreement, then Siebel CRM requires the user to associate a decision maker with the opportunity. Otherwise, Siebel CRM resets it to the previous value. To determine if a vice president or president is associated with the opportunity, Siebel CRM searches the contacts that it associates with the opportunity.

The following steps describe the logical flow of object interface methods that Siebel CRM uses to create a new business component instance:

  1. GetBusComp.
  2. SetViewMode. This method is optional. You can use it to modify the default value of the view mode.
  3. ActivateField.
  4. ClearToQuery.
  5. SetSearchSpec or SetSearchExpr.

    It is not necessary to activate a field that includes a search specification and a search expression, unless the GetFieldValue method or the SetFieldValue method also references this field.

  6. ExecuteQuery.
Example of Using Siebel VB to Access Data from a New Business Component Instance

The following example uses Siebel VB to access data from a new business component instance:

Function BusComp_PreSetFieldValue (FieldName As String, FieldValue As String) As Integer

Dim RetValue As Integer
RetValue = ContinueOperation
Select Case FieldName
   Case "Sales Stage"
      If FieldValue = "08 - Negotiation" Then
         ' Do not allow the sales cycle to be changed to this value
         ' if the decision-maker is not a contact for the Oppty.
         ' Decision-maker defined as anyone with rank VP and above
         Dim oBusObj As BusObject
         Dim sRowId As String
         Dim iViewMode As Integer
         sRowId = GetFieldValue("Id")
         iViewMode = GetViewMode
         Set oBusObj = TheApplication.ActiveBusObject

         ' Parent-child relationship is established if
         ' BusComps are instantiated from the same BusObject.
         ' The ContactBC has all contact records for the
         ' current Oppty record.
         Set ContactBC = oBusObj.GetBusComp("Contact")
         With ContactBC
            .ClearToQuery
            .SetSearchSpec "Job Title", "*VP*"
            .ExecuteQuery ForwardBackward
            If (.FirstRecord = 1) Then
               TheApplication.RaiseErrorText "Found a decision maker"
            Else
               RetVal = ContinueOperation
            End If
         End With
         Set ContactBC = Nothing
         Set oBusObj = Nothing
      End If
End Select
BusComp_PreSetFieldValue = RetValue
End Function

Example of Using Siebel eScript to Access Data from a New Business Component Instance

The following example uses Siebel eScript to access data from a new business component instance:

function BusComp_PreSetFieldValue (FieldName, FieldValue)
{
   var RetValue = ContinueOperation;
   switch (FieldName)
   {
      case "Sales Stage":
      if (FieldValue == "08 - Negotiation")
      {
      //Do not allow the sales cycle to be changed to this value
      //if the decision-maker is not a contact for the Oppty.
      //Decision-maker defined as anyone with rank VP and above
         var oBusObj;
         var sRowId;
         var iViewMode;
         sRowId = this.GetFieldValue("Id");
         iViewMode = this.GetViewMode();
         oBusObj = TheApplication().ActiveBusObject();
         //Parent-child relationship is established if
         //BusComps are instantiated from the same BusObject.
         //The ContactBC has all contact records for the
         //current Oppty record.
         ContactBC = oBusObj.GetBusComp("Contact");
         with (ContactBC)
         {
            ClearToQuery();
            SetSearchSpec("Job Title", "*VP*");
            ExecuteQuery(ForwardBackward);
            if (FirstRecord())
            {
               TheApplication().RaiseErrorText("Found a decision maker");
            }
            else
            {
               RetVal = ContinueOperation;
            }
         }
         ContactBC = null;
         oBusObj = null;
      }
      break;
   }
return(RetVal);
}

Methods That Get Data From Business Components

The following object interface methods get data from a business component:

Siebel Object Interfaces Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.