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:
- Explicitly by issuing BusComp.WriteRecord
- Navigating away from the current record by any of the following methods:
- BusComp.DeleteRecord (DeleteRecord commits automatically, because it moves the cursor to another record.)
- Closing a BusComp (Set BusComp = Nothing)
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
desc = Me.GetFieldValue("Description")
TheApplication.Trace "The previous description is " & desc
Me.SetFieldValue "Description", newDesc
TheApplication.Trace "The new description is " & newDesc
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:
- SetViewMode (optional, unless you want to change the view mode from the default)
- SetSearchSpec or SetSearchExpr
NOTE: It is not necessary to activate fields on which search specs and search expressions are set, unless the fields are also referenced by the GetFieldValue or SetFieldValue method.
The following example shows how to instantiate objects in eScript:
function BusComp_PreSetFieldValue (FieldName, FieldValue)
var RetValue = ContinueOperation;
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
sRowId = this.GetFieldValue("Id");
iViewMode = this.GetViewMode();
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.
ContactBC = oBusObj.GetBusComp("Contact");
SetSearchSpec("Job Title", "*VP*");
TheApplication().RaiseErrorText("Found a decision maker");
RetVal = ContinueOperation;
ContactBC = null;
oBusObj = null;
The following example shows how to instantiate objects in Siebel VB:
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")
.SetSearchSpec "Job Title", "*VP*"
If (.FirstRecord = 1) Then
TheApplication.RaiseErrorText "Found a decision maker"
RetVal = ContinueOperation
Set ContactBC = Nothing
Set oBusObj = Nothing
BusComp_PreSetFieldValue = RetValue
Methods for Accessing Business Components
To access business components, use the following methods: