Applying Multiple Object Interface Methods to a Single Object

To apply multiple object interface methods to a single object, you can use the With statement in Siebel VB or Siebel eScript. It reduces typing and makes the code easier to read.

Example of Using the With Statement in Siebel VB

The following example uses the With statement in Siebel VB:

Set oBusObject = TheApplication.GetBusObject("Opportunity")
Set oBusComp = oBusObject.GetBusComp("Opportunity")
With oBusComp
   .ActivateField "Account"
   .ClearToQuery
   .SetSearchSpec "Name", varname
   .ExecuteQuery ForwardBackward
   If (.FirstRecord = 1) Then
      sAccount = .GetFieldValue "Account"
   End If
End With
. . .

Set oBusComp = Nothing
Set oBusObject = Nothing

The following example is not recommended. It does not use the With statement:

Set oBusObject = TheApplication.GetBusObject("Opportunity")
Set oBusComp = oBusObject.GetBusComp("Opportunity")
oBusComp.ActivateField "Account"
oBusComp.ClearToQuery 
oBusComp.SetSearchSpec "Name", varname
oBusComp.ExecuteQuery ForwardBackward
If (oBusComp.FirstRecord = 1) Then
   sAccount = oBusComp.GetFieldValue "Account"
End If
. . .

Example of Using the With Statement in Siebel eScript

The following example uses the With statement in Siebel eScript:

var oBusObject = TheApplication().GetBusObject("Opportunity");
var oBusComp = oBusObject.GetBusComp("Opportunity");
with (oBusComp)
{
   ActivateField("Account");
   ClearToQuery();
   SetSearchSpec("Name", varname);
   ExecuteQuery(ForwardBackward);
   if (FirstRecord())
   {
      var sAccount = GetFieldValue( "Account");
   }
} //end with

The following example is not recommended. It does not use the With statement:

var oBusObject = TheApplication().GetBusObject("Opportunity");
var oBusComp = oBusObject.GetBusComp("Opportunity");
oBusComp.ActivateField("Account");
oBusComp.ClearToQuery(); 
oBusComp.SetSearchSpec("Name", varname);
oBusComp.ExecuteQuery(ForwardBackward);
if oBusComp.FirstRecord(); 
{
   var sAccount = oBusComp.GetFieldValue("Account");
}
. . .