Siebel eScript Language Reference > Statements Reference > Guidelines for Using Siebel eScript >

With Statement


The With statement associates a default object with a statement block. It only applies to the code that resides in the statement block where the With statement occurs, regardless of how Siebel eScript enters or exits the statement block. If Siebel eScript exits a With statement, then the With statement no longer applies.

You cannot write code that uses a Goto statement or a label to enter or exit the middle of a statement block that resides in a With statement.

Format

with (object)
{
     method1;
     method2;
     .
     .
     .
     methodn;
}

Table 27 describes the arguments of the With statement.

Table 27. Arguments of the With Statement
Argument
Description

object

An object where you must use multiple methods.

method1, method2, methodn

Methods that Siebel eScript runs with the object. The With statement prefixes each method with the object name and a period.

Example

The following example includes a With statement:

var bcOppty;
var boBusObj;
boBusObj = TheApplication().GetBusObject("Opportunity");
bcOppty = boBusObj.GetBusComp("Opportunity");
var srowid = bcOppty.GetFieldValue("Id");

try
{
   with (bcOppty)
   {
      SetViewMode(SalesRepView);
      ActivateField("Sales Stage");
      SetSearchSpec("Id", srowid);
      ExecuteQuery(ForwardOnly);
   }
}
finally
{
   boBusObj = null;
   bcOppty = null;
}

The code in the With statement block is equivalent to the following code:

bcOppty.SetViewMode(SalesRepView);
bcOppty.ActivateField("Sales Stage");
bcOppty.SetSearchSpec("Id", srowid);
bcOppty.ExecuteQuery(ForwardOnly);

Siebel eScript Language Reference Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.