Siebel Object Interfaces Reference > Programming > Siebel Object Interface Methods >

Accessing Business Components


The Siebel business component object (BusComp) presents a two-dimensional grid of data values much like a table in a relational database. The named fields are analogous to columns in the database table, and the records are analogous to rows. Developers use business components to read data, manipulate it, and write it back into the Siebel database. Business components manage the complexities of multiple-table access to the database and access different types of databases.

Many methods are available to use on business components for getting and setting the values of their fields. Record operations can be performed programmatically by using business component access methods.

These operations invoke Siebel VB or Siebel eScript extension routines. For example, if you have created a Siebel VB or Siebel eScript script that is tied to the NewRecord event on a business component, the script is processed whenever NewRecord in that business component is processed, even if the NewRecord method was called by another Siebel VB or Siebel eScript script or was called from the Siebel object interfaces. Note that events are available only with Siebel VB or Siebel eScript.

Adding and Inserting Records

In the context of a many-to-many relationship, you can use Siebel VB or Siebel eScript to mimic either the Add New Record command, which associates a new child record, or the Insert Record command, which creates a new record in the child business component. To associate a new child record, use GetAssocBusComp and the Associate method. To create a new record in the child, use the NewRecord method in a child business component, or use GetMVGBusComp and the NewRecord method.

Committing Records to the Database

A commit is performed under the following circumstances:

Scenarios for Business Components

The two scenarios that follow involve the use of Siebel scripts to work with business components.

The first example shows how to invoke methods on an existing business component when an event is triggered. In this example, the VB script is in the SetFieldValue event of a 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 which 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

The next example shows how to instantiate your own BusObject and BusComp. This example uses the PreSetFieldValue event of the Opportunity BusComp. If the Sales Stage is updated to "07 - Verbal Agreement," a decision maker must be associated with the opportunity. Otherwise, it is reset to the previous value. The Contacts for the selected opportunity are searched to see if any vice president or president is associated with the opportunity.

The logical flow of instantiating your own BusComp object is as follows

  1. GetBusComp
  2. SetViewMode (optional, because the BusComp may already be in the correct mode)
  3. ActivateField
  4. ClearToQuery
  5. SetSearchSpec or SetSearchExpr
  6. ExecuteQuery
  7. 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

             ' Because parent-child relationship is established when
             ' 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
                .ActivateField "Job Title"
                .ClearToQuery
                .SetSearchSpec "Job Title", "*VP*"
                .ExecuteQuery ForwardOnly
                If (.FirstRecord = 0) Then
                TheApplication.RaiseErrorText "Found a decision maker"
                RetValue = CancelOperation
                Else
                   RetVal = ContinueOperation
                End If
             End With
          End If
    End Select
    BusComp_PreSetFieldValue = RetValue
    End Function

Methods for Accessing Business Components

To access business components, use the following methods.


 Siebel Object Interfaces Reference 
 Published: 18 June 2003