Siebel Object Interfaces Reference > Siebel Object Interfaces Reference > Object Interfaces Reference >

Application Methods


This topic describes application methods. It includes the following topics:

Overview of Application Methods

An application method is a predefined methods that return the current Siebel application object instance:

  • TheApplication, if called from Siebel VB that resides in the Siebel runtime repository
  • TheApplication(), if called from Siebel eScript that resides in the Siebel runtime repository
  • theApplication(), if called from Browser Script that resides in the Siebel runtime repository

Note the following:

  • If an application method applies to only one scripting language, then the Syntax definition in the method includes one of these methods.
  • If a method applies to an external interface or to more than one scripting language, then it must use more than one format. In this situation, the Syntax definition includes Application and results in the following situation:
    • If you use Siebel VB, Siebel eScript, or Browser Script, then Siebel CRM substitutes the applicable statement for Application
    • If you use an external interface, then Siebel CRM substitutes the name of an application instance for Application

Some examples in this chapter include an Application method that uses an external interface. These examples use SiebelApplication as the application instance. The examples assume that the script starts an instance of the Siebel application. This situation is true even if the example does not include the code that starts this instance.

ActiveApplet Method for an Application

The ActiveApplet method returns a reference to the applet that Siebel CRM displays.

Format

theApplication().ActiveApplet();

No arguments are available.

Usage

Use this method to identify the applet that Siebel CRM currently displays. This applet typically includes a blue border to indicate that it is active.

Used With

Browser Script

Examples

function Applet_PreInvokeMethod (name, inputPropSet)
{
   switch (name)
   {
      case "Drilldown":
         var activeapplet = theApplication().ActiveApplet();
         var activeappletname = activeapplet.Name();
         theApplication().SWEAlert("Here is the applet we are drilling down from "
         + activeappletname);
      break;
   }
   return ("ContinueOperation");
}

ActiveBusComp Method for an Application

The ActiveBusComp method returns the name of the business component that the active applet references.

Format

theApplication().ActiveBusComp();

No arguments are available.

Used With

Browser Script

Examples

function Applet_Load ()
{
   var activeBC = theApplication().ActiveBusComp();
   activeBC = activeBC.Name();
   theApplication().SWEAlert(activeBC);
}

ActiveBusObject Method for an Application

The ActiveBusObject method returns the name of the business object that the active view references.

Format

Application.ActiveBusObject

No arguments are available.

Usage for the ActiveBusObject Method

Do not use the ActiveBusObject method in an event handler that any of the following technologies can start:

  • COM Data Server
  • COM Data Control
  • Siebel Java Data Bean
Used With

Browser Script, Mobile Web Client Automation Server, Server Script

Example in Browser Script

The following example is in Browser Script:

function Applet_Load ()
{
   var oBusObj;
   oBusObj = theApplication().ActiveBusObject();
   theApplication().SWEAlert("The active business object is " + oBusObj.Name() + ".")
}

Example of Using the ActiveBusObject Method to Call from a Custom Button on a Child Applet

The following examples include script that runs on the Siebel Server that Siebel CRM can call from a custom button on a child applet in a view. This script does the following work:

  1. Determines if the Contact business object is active. If it is active, then Siebel CRM returns the email address of the currently active parent Contact record.
  2. Uses the contact email address to call the custom SendEmail function.

Objects that the script references are currently active in the Siebel client, so Siebel CRM does not delete these objects at the end of the script.

The following example is in Siebel eScript:

function WebApplet_PreInvokeMethod (MethodName)
{
   if (MethodName == "Send Email")
   {
      var oBO = TheApplication().ActiveBusObject();

      if (oBO.Name() == "Contact")
      {
        var oBC = oBO.GetBusComp("Contact");
         var sEmail = oBC.GetFieldValue("Email Address");

         SendMail(sEmail);

         sEmail ="";
       }
      return (CancelOperation);
   }
   return (ContinueOperation);
}

The following example is in Siebel VB:

Function WebApplet_PreInvokeMethod (MethodName As String) As Integer

   Dim iRtn As Integer
   iRtn = ContinueOperation

   If MethodName = "Send Email" Then

     Dim oBO As BusObject
      Set oBO = TheApplication.ActiveBusObject()

      If oBO.Name() = "Contact" Then

         Dim oBC As BusComp
         Dim sEmail As String

         Set oBC = oBO.GetBusComp("Contact")

         sEmail = oBC.GetFieldValue("Email Address")

         SendEmail(sEmail)

         sEmail =""

      End If

      iRtn = CancelOperation

   End If

   WebApplet_PreInvokeMethod = iRtn
End Function

ActiveViewName Method for an Application

The ActiveViewName method returns the name of the active view.

Format

Application.ActiveViewName

No arguments are available.

Usage

Usage for the ActiveViewName method is very similar to usage for the ActiveViewName method. For more information, see Usage for the ActiveBusObject Method.

Used With

Browser Script, Mobile Web Client Automation Server, Server Script

Examples

The following example is in Siebel eScript:

function BusComp_PreSetFieldValue (FieldName, FieldValue)
{
   switch(FieldName)
   {
   case "Name":
   case "Location":
   case "Account Status":
   case "Alias":
   case "City":
   case "Country":
   case "Currency Code":
   case "Current Volume":
   case "DUNS Number":
   case "Expertise":
   case "Freight Terms":
   case "Freight Terms Info":
   case "Home Page":
   case "Industry":
   case "Location":
   case "Main Phone Number":
   case "Main Fax Number":
   case "Sales Rep":
   var sActiveViewName = TheApplication().ActiveViewName();
   if (sActiveViewName == "All Accounts across Organizations")
   {
      TheApplication().RaiseErrorText("You cannot update the " + FieldName +
         " on the " + sActiveViewName + " View");
   }
   break;
   }
   return (ContinueOperation);
}

Attach Method for an Application

The Attach method allows an external application to reconnect to an existing Siebel session. It returns a Boolean value that indicates if Siebel CRM successfully ran the method.

Format

Application.Attach(sessionString)

Table 26 describes the arguments for the Attach method.

Table 26. Arguments for the Attach Method
Argument
Description

sessionString

A string that contains the Siebel Session Id. This argument is typically the output of the Detach method.

Used With

COM Data Control, Siebel Java Data Bean

Examples

The examples in this topic do the following work:

  1. Start an instance of COM Data Control.
  2. Log in to a Siebel Server.
  3. Detach the instance.
  4. Determine the session string.
  5. Start another instance of COM Data Control.

    The script does not log in again. Instead, it uses the session string to access the existing session. This technique reuses the connection that the first instance created.

The following example uses COM Data Control and is written in native Visual Basic:

Dim SiebelApplication_first As SiebelDataControl
Dim SiebelApplication_second As SiebelDataControl
Dim errCode As Integer
Dim sessionString As String
Dim attachResult As Boolean
Dim errText As String

' Instantiate the first instance
Set SiebelApplication_first = CreateObject("SiebelDataControl.SiebelDataControl.1")

' Login to Siebel
SiebelApplication_first.Login "host=""Siebel.tcpip.none.none://virtual ip:port/enterprise/object manager""", "user id", "password"

errCode = SiebelApplication_first.GetLastErrCode
If errCode <> 0 Then
   errText = SiebelApplication_first.GetLastErrText
   MsgBox errText
   Exit Sub
End If

' Detach this instance from Siebel and get session id
sessionString = SiebelApplication_first.Detach
MsgBox "The session string is: " & sessionString

' Instantiate the second instance
Set SiebelApplication_second = CreateObject("SiebelDataControl.SiebelDataControl.1")

' Attach the existing session to this instance
attachResult = SiebelApplication_second.Attach(sessionString)
If (attachResult = True) Then
   MsgBox "Session attached!"
Else
   MsgBox "Session attach failed"
End If

SiebelApplication_second.LogOff
Set SiebelApplication_second = Nothing
Set SiebelApplication_first = Nothing

The following example uses the Siebel Java Data Bean:

import com.siebel.data.*;
import com.siebel.data.SiebelException;

public class JDBAttachDetachDemo
{
   private SiebelDataBean m_dataBean_first = null;
   private SiebelDataBean m_dataBean_second = null;

   public static void main(String[] args)
   {
      JDBAttachDetachDemo demo = new JDBAttachDetachDemo();
   }

   public JDBAttachDetachDemo()
   {
      try
      {
         // Instantiate the Siebel Java Data Bean
         m_dataBean_first = new SiebelDataBean();

         // Login to the Siebel Servers
         m_dataBean_first.login("siebel.tcpip.none.none://virtualip:2320/
          enterprise/object manager name","user id","password");

         System.out.println("Logged in to the Siebel Server ");

         //Get the Detach Handle
         String detachHandle = m_dataBean_first.detach();
         System.out.println("The session id is: " + detachHandle);

         // Instantiate another Siebel Java Data Bean
         SiebelDataBean m_dataBean_second = new SiebelDataBean();

         // Do Attach
         System.out.println("Attaching in to the Siebel Server ");
         m_dataBean_second.attach(detachHandle);
         System.out.println("Attach Done ");

         // Logoff
         m_dataBean_second.logoff();
      }

      catch (SiebelException e)
      {
         System.out.println(e.getErrorMessage());
      }
   }
}

CurrencyCode Method for an Application

The CurrencyCode method returns the currency code that is associated with the division of the user position. For example, USD for U.S. dollars, EUR for the euro, or JPY for the Japanese yen.

Format

Application.CurrencyCode

No arguments are available.

Used With

Browser Script, COM Data Control, COM Data Server, Web Client Automation Server, and Server Script

Examples

The following example is in Siebel eScript:

function WebApplet_Load ()
{
   var currencycode;
   currencycode = TheApplication().CurrencyCode();
   var WshShell = COMCreateObject("WScript.Shell");
   WshShell.Popup(currencycode);
}

Detach Method for an Application

The Detach method returns a string that contains the Siebel session Id.

Format

Application.Detach

No arguments are available.

Usage

Use the string that the Detach method returns only with the Attach method.

Used With

COM Data Control, Siebel Java Data Bean

Examples

For a Siebel Java Data Bean example and a native VB example that uses COM Data Control, see Attach Method for an Application.

EnableExceptions Method for an Application

The EnableExceptions method enables or disables native Component Object Model (COM) error handling. This method does not return any information.

Format

Application.EnableExceptions(bEnable)

Table 27 describes the arguments for the EnableExceptions method.

Table 27. Arguments for the EnableExceptions Method
Argument
Description

bEnable

You can one of the following values:

  • TRUE
  • FALSE

Usage

Setting the argument to TRUE enables native error handling. This allows Siebel CRM to intercept and display the exception ID and description. Native COM error handling is disabled by default.

Used With

COM Data Control, Mobile Web Client Automation Server

Example of Using the EnableExceptions Method with Siebel ActiveX Data Control

The native Visual Basic script in this example does the following work:

  • Uses the Siebel ActiveX Data Control to connect to the Siebel application and to create an instance of a business object.
  • Prompts the user to use or not use the native error handling.
  • If the user answers yes, and if the script encounters an error, then it issues the error immediately.
  • If the user answers no, then the script suppresses errors.

    You can detect errors only with the GetLastErrCode method.

The following code is an example of using the EnableExceptions method with Siebel ActiveX Data Control:

Dim SiebelApplication As SiebelDataControl
Dim errCode As Integer
Dim wrongBO As SiebelBusObject

Dim nativeHandle As String

Set SiebelApplication = CreateObject("SiebelDataControl.SiebelDataControl.1")

' Login to Siebel

SiebelApplication_first.Login "host=""Siebel.tcpip.none.none://virtual ip:port/enterprise/object manager""", "user id", "password"

nativeHandle = InputBox("Use native error handling?", "", "Yes")

If nativeHandle = "Yes" Then
   SiebelApplication.EnableExceptions (True)
Else
   SiebelApplication.EnableExceptions (False)
End If

Set wrongBO = SiebelApplication.GetBusObject("No Such One") 'intended to create an error at this line by instantiating a nonexisting Business Object

errCode = SiebelApplication.GetLastErrCode()
If errCode <> 0 Then 'if native error handle is disabled, this block detects it
   ErrText = SiebelApplication.GetLastErrText
   MsgBox ErrText
   Exit Sub
End If

Example of Using the EnableExceptions Method with Siebel Mobile Automation Server

The script in this example performs the same work that is described in Example of Using the EnableExceptions Method with Siebel ActiveX Data Control, except it uses the Siebel Mobile Automation Server:

Dim SiebelApp As SiebelWebApplication
Dim errCode As Integer
Dim wrongBO As SiebelBusObject

Set SiebelApp = CreateObject("TWSiebel.SiebelWebApplication.1")

Dim nativeHandle As String
nativeHandle = InputBox("Use native error handle?", "", "Yes")

If nativeHandle = "Yes" Then
   SiebelApp.EnableExceptions (True)
Else
   SiebelApp.EnableExceptions (False)
End If

Set wrongBO = SiebelApp.GetBusObject("No Such One") 'intended to create an error at this line by instantiating a nonexisting Business Object

errCode = SiebelApp.GetLastErrCode()
If errCode <> 0 Then 'if native error handle is disabled, this block detects it
   ErrText = SiebelApp.GetLastErrText
   MsgBox ErrText
   Exit Sub
End If

FindApplet Method for an Application

The FindApplet method returns the name of an applet.

Format

theApplication().FindApplet(appletName)

Table 28 describes the arguments for the FindApplet method.

Table 28. Arguments for the FindApplet Method
Argument
Description

appletName

String variable or literal that contains the name of an applet.

Usage

The only applets available are applets that are visible in the active view.

Used With

Browser Script

Examples

The following example is in Browser Script:

function Applet_ChangeFieldValue (field, value)
{
   if (theApplication().ActiveViewName() == "Account List View")
   {
      var newapplet = theApplication().FindApplet("Account Entry Applet");
      var entryappletcontrol = newapplet.FindControl("Name");
      var entryappletvalue = entryappletcontrol.GetValue();
      theApplication().SWEAlert(entryappletvalue);
   }
}

GetBusObject Method for an Application

The GetBusObject method creates a new instance of a business object. It returns the name of this new business object instance.

Format

Application.GetBusObject(busObjectName)

Table 29 describes the arguments for the GetBusObject method.

Table 29. Arguments for the GetBusObject Method
Argument
Description

busObjectName

String variable or literal that contains the name of the business object.

Usage

To delete the business object instance after it is no longer needed, you can set the business object to Nothing.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

The examples in this topic create a new instance of the Account business object and returns the name of the instance of the Account business object.

The following example is in Siebel eScript:

var oBusObject = TheApplication().GetBusObject("Account");
var oBusComp = oBusObject.GetBusComp("Account");

Your custom code

oBusComp = null;
oBusObject = null;

The following example is in Siebel VB:

Dim AccntBO as BusObject
Dim AccntBC as BusComp
Dim AddrBC as BusComp
Set AccntBO = TheApplication.GetBusObject("Account")
Set AccntBC = AccntBO.GetBusComp("Account")

Your custom code

Set AccntBO = Nothing
Set AccntBC = Nothing

Examples of Using the GetBusObject Method to Refer to the Business Object That Is Currently Active

The name of the business object instance that Siebel CRM returns might vary depending on the location where it calls the code, such as a Web applet event. The examples in this topic are useful if you must refer to the business object instance that is currently active.

The following example is for Siebel Java Data Bean:

private SiebelDataBean m_dataBean = null;
private SiebelBusObject m_busObject = null;
m_busObject = m_dataBean.getBusObject("Opportunity");

The following example is in Siebel eScript:

var oBO = TheApplication().GetBusObject(this.BusObject.Name);

The following example is in Siebel VB:

Dim oBO as BusObject
Dim oBC as BusComp
Set oBO = TheApplication.GetBusObject(Me.BusObject.Name)

GetDataSource Method for an Application

The GetDataSource method returns the name of the data source that Siebel CRM defines in the DataSource server parameter for the session. The default value is ServerDataSrc.

Format

dataSrc = Application.InvokeMethod("GetDataSource")

No arguments are available.

Used With

To use this method, you can use an Application.InvokeMethod call with the following interfaces:

  • COM Data Control
  • Siebel Java Data Bean
  • Mobile Web Client Automation Server
  • Server Script
Examples

The following Siebel eScript code detects the data source and displays the name of the data source in a dialog box:

var dataSrc = TheApplication().InvokeMethod("GetDataSource");
TheApplication().RaiseErrorText(dataSrc);

The following example is in Siebel VB:

Dim dataSrc As String
dataSrc = TheApplication.InvokeMethod("GetDataSource")
TheApplication.RaiseErrorText(dataSrc)

GetLastErrCode Method for an Application

The GetLastErrCode method returns the error code for the error that Siebel CRM logged most recently. This code is a short integer. 0 (zero) indicates no error.

Format

Application.GetLastErrCode

No arguments are available.

Usage for the GetLastErrCode Method

After you run an object interface method, you can call the GetLastErrCode method to determine if Siebel CRM returned an error from the previous operation. You can use the GetLastErrText method to return the text of the error message. Each call to a method resets the run status. For more information, see GetLastErrText Method for an Application.

Used With

COM Data Control, Mobile Web Client Automation Server, Web Client Automation Server

Examples

The following example is for COM Data Control:

errcode = SiebelApplication.GetLastErrCode
If errcode <> 0 Then
   ErrText = SiebelApplication.GetLastErrText
   MsgBox ErrText
   Exit Sub
End If

GetLastErrText Method for an Application

The GetLastErrText method returns a string that contains the text message for the error that Siebel CRM logged most recently.

Format

Application.GetLastErrText

No arguments are available.

Usage for the GetLastErrText Method

The text that the GetLastErrText method returns includes a Siebel error code that you can use to investigate the error. For more information, see GetLastErrCode Method for an Application. For more information about a specific error, see My Oracle Support.

Used With

COM Data Control, COM Data Server, Mobile Web Client Automation Server, Web Client Automation Server

Examples

The following example is for COM Data Control:

errcode = SiebelApplication.GetLastErrCode
If errcode <> 0 Then
   ErrText = SiebelApplication.GetLastErrText
   MsgBox ErrText
   Exit Sub
End If

GetProfileAttr Method for an Application

The GetProfileAttr method returns the name of an attribute in a user profile. For more information, see SetProfileAttr Method for an Application.

Format

Application.GetProfileAttr(name)

Table 30 describes the arguments for the GetProfileAttr method.

Table 30. Arguments for the GetProfileAttr Method
Argument
Description

name

A string that indicates the name of the attribute.

Usage

For more information, see Using System Fields with the SetProfileAttr Method.

Used With

Browser Script, COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

The following example is in Browser Script:

var myprofile = theApplication().GetProfileAttr("Hobby");

The following example is in Siebel eScript:

var myprofile = TheApplication().GetProfileAttr("Hobby");

The following example is in Siebel VB:

Dim myprofile As String
myprofile = TheApplication.GetProfileAttr("Hobby")

GetService Method for an Application

The GetService method locates a business service. If this business service is not already running, then Siebel CRM starts it. This method returns the name of the business service.

Format

Application.GetService(serviceName)

Table 31 describes the arguments for the GetService method.

Table 31. Arguments for the GetService Method
Argument
Description

serviceName

The name of the business service to start.

Usage

The GetService method searches through the predefined services that are stored in the Siebel runtime repository. If it does not find the business service that you specify in the serviceName argument, then it searches the business services defined in the run-time Business Services table.

Siebel CRM normally deletes a business service from memory as soon as it clears all references to this business service. The act of setting the business service to another value usually clears these references. If you set the Cache property on the business service to TRUE, then Siebel CRM keeps this business service in memory as long as the Siebel application is running.

Registering a Business Service with a Siebel Application

Starting with Siebel CRM version 8, if you use the Web Client Automation Server or Browser Script to call a business service, then you must register that business service with the Siebel application. You must do this to prevent a Service Not Found error. It is not necessary to specify this business service in the CFG file. This requirement does not apply to Server Script.

To register a business service with a Siebel application

  1. In Siebel Tools, in the Object Explorer, click Application.
  2. In the Applications list, locate the Siebel application you must modify.

    For example, Siebel Universal Agent.

  3. In the Object Explorer, expand the Application tree, and then click Application User Prop.
  4. In the Application User Props list, create new application user properties using values from the following table.
    Name
    Value

    ClientBusinessService0

    XML Converter

    ClientBusinessService1

    My Business Service

    You must enter the ClientBusinessService records sequentially, starting with ClientBusinessService0 and incrementing by 1 for each new ClientBusinessService user property you add.

Used With

Browser Script, COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script, Web Client Automation Server

Examples

The following examples start a new instance of a business service named Workflow Process Manager.

The following example is in Browser Script:

function Applet_PreInvokeMethod (name, inputPropSet)
{
   if (name == "MyCustomMethod")
   {
      var oBS;
      var inpPS;
      var outPS;
      inpPS = theApplication().NewPropertySet();
      outPS = theApplication().NewPropertySet();
      oBS = theApplication().GetService("Workflow Process Manager");
      outPS = oBS.InvokeMethod("RunProcess", inpPS);
      inpPS = null;
      outPS = null;
      return ("CancelOperation");
   }
   else
   {
      return ("ContinueOperation");
   }
}

The following example is in Siebel eScript:

function WebApplet_PreInvokeMethod (MethodName)
{
   if (MethodName == "MyCustomMethod")
   {
      var oBS;
      var inpPS;
      var outPS;
      inpPS = TheApplication().NewPropertySet();
      outPS = TheApplication().NewPropertySet();
      oBS = TheApplication().GetService("Workflow Process Manager");
      oBS.InvokeMethod("RunProcess", inpPS, outPS);
      inpPS = null;
      outPS = null;
      oBS = null;
      return (CancelOperation);
   }
   else
   {
      return (ContinueOperation);
   }
}

The following example is in Siebel VB:

Function WebApplet_PreInvokeMethod (MethodName As String) As Integer
If MethodName = "MyCustomMethod" Then
   Dim oBS As Service
   Dim inpPS As PropertySet
   Dim outPS As PropertySet
   Set inpPS = TheApplication.NewPropertySet
   Set outPS = TheApplication.NewPropertySet
   Set oBS = TheApplication.GetService("Workflow Process Manager")
   oBS.InvokeMethod "RunProcess", inpPS, outPS
   Set inpPS = Nothing
   Set outPS = Nothing
   Set oBS = Nothing
   WebApplet_PreInvokeMethod = CancelOperation
Else
   WebApplet_PreInvokeMethod = ContinueOperation
End If
End Function

GetSharedGlobal Method for an Application

The GetSharedGlobal method returns the shared global variables. A shared variable is a type of variable that any script in the user session can access. It is shared among all scripts.

A shared global variable is unique to the user and the user session. A global variable for a given user is not visible to any other user. A global variable is visible only to the current user and user session. You can access the global variable from any event.

Format

Application.GetSharedGlobal(varName)

Table 32 describes the arguments for the GetSharedGlobal method.

Table 32. Arguments for the GetSharedGlobal Method
Argument
Description

varName

String literal or variable that contains the name of the global variable.

Usage

Consider the following code:

GetSharedGlobal("varName")

This code returns the string that the following code sets:

SetSharedGlobal "varName", "stringValue".

Used With

COM Data Control, COM Data Server, Mobile Web Client Automation Server, Server Script

Example of Using the GetSharedGlobal Method

To get the myGlobalVar global variable, the examples in this topic call the GetSharedGlobal method in the BusComp_WriteRecord event. This global variable is set through the SetSharedGlobal method in the Application_Start event. For more information, see SetSharedGlobal Method for an Application.

The following example is for the Component Object Model (COM):

Dim sReturn as String
oleVar = SiebelApplication.GetSharedGlobal("myGlobalVar", errCode)
SiebelApplication.SetSharedGlobal "myGlobalVar", " helloworld", errCode

The following example is in Siebel eScript:

function Application_Start (CommandLine)
{
   TheApplication().SetSharedGlobal("myGlobalVar", "helloworld");
}

function BusComp_WriteRecord ()
{
   var myVar;
   myVar = TheApplication().GetSharedGlobal("myGlobalVar");
}

The following example is in Siebel VB:

Sub Application_Start (CommandLine As String)
   TheApplication.SetSharedGlobal "myGlobalVar", "helloworld"
End Sub

Sub BusComp_WriteRecord
   Dim myVar as String
   myVar = TheApplication.GetSharedGlobal("myGlobalVar")
End Sub

GotoView Method for an Application

The GotoView method does the following work:

  1. Deactivates any business object, business component, applet, or control that is active.
  2. Activates a view.
  3. Creates an instance of the business object that the view references. This business object instance becomes the active business object.
  4. Activates the primary applet of the view and the business component that this applet references.
  5. Activates the first tab sequence control of the primary applet.

This method does not return any information.

Format

Application.GotoView(ViewName[, BusinessObjectName])

Table 33 describes the arguments for the GotoView method.

Table 33. Arguments for the GotoView Method
Argument
Description

ViewName

The name of the view that the Siebel application must display.

BusinessObjectName

Optional. The business object that Siebel CRM uses to display the view. You cannot specify the current active business object. If you do not provide this argument, or if you specify Nothing in this argument, then Siebel CRM activates a new business object in the normal way.

Usage

If an instance of the business object does not exist, then you must set the value for the BusinessObjectName argument to Nothing.

You cannot use the GotoView method in the following events:

  • Application_Navigate
  • Application_PreNavigate
  • Application_Start
  • Navigate
  • PreNavigate
  • WebApplet_Load

The following Siebel VB script uses GotoView to programmatically navigate to the Opportunity List view:

TheApplication.GotoView "Opportunity List View", Nothing

If your Siebel application already started an instance of an Opportunity object with the object reference of objOppty, then the following usage in Siebel VB is acceptable:

TheApplication.GotoView "Opportunity List View", objOppty

If you use the GotoView method in a Siebel VB or Siebel eScript script, then Siebel CRM runs the method last. This situation is true regardless of where you use this method in the script.

If script on a control uses the GotoView method, then do not set the Show Popup property on this control to TRUE. If you set the Show Popup to TRUE in this situation, then Siebel CRM opens the view in a new browser window. You cannot use a Multiple Document Interface (MDI) with the Siebel client, so you cannot use this configuration.

Used With

Server Script

Examples

The following examples use the GoToView method with and without the optional business object parameter.

The following example is in Siebel eScript:

function BusComp_WriteRecord ()
{
   var leadQuality;
   var actName;
   var actBO;
   var actBC;

   //Get the lead quality for this opportunity
   leadQuality = this.GetFieldValue("Quality");
   if(leadQuality == "1-Excellent")
   {

      //If it is a excellent lead,
      //go to the account for this opportunity
      actName = this.GetFieldValue("Account");
      actBO = TheApplication().GetBusObject("Account");
      actBC = actBO.GetBusComp("Account");

      with (actBC)
      {
         SetViewMode(AllView);
         ClearToQuery();
         SetSearchSpec("Name", actName);
         ExecuteQuery(ForwardBackward);
      }

      TheApplication().GotoView("All Account List View",actBO);

   }
   else
   {
      TheApplication().GotoView("Opportunity Detail - Activities View");
   }

   actBC = null;
   actBO = null;

}

The following example is in Siebel VB:

Sub BusComp_WriteRecord

   Dim leadQuality As String
   Dim actName As String
   Dim actBO As BusObject
   Dim actBC As BusComp

   'Get the lead quality For this opportunity
   leadQuality = Me.GetFieldValue("Quality")
   If (leadQuality = "1-Excellent") Then

      'If it is an excellent lead
      'go to the account For this opportunity
      actName = Me.GetFieldValue("Account")
      Set actBO = TheApplication.GetBusObject("Account")
      Set actBC = actBO.GetBusComp("Account")

      With actBC
         .SetViewMode AllView
         .ClearToQuery
         .SetSearchSpec "Name", actName
         .ExecuteQuery
      End With

      TheApplication.GotoView "All Account List View",actBO

   Else
      TheApplication.GotoView "Opportunity Detail - Activities View"
   End If

   Set actBC = Nothing
   Set actBO = Nothing

End Sub

InvokeMethod Method for an Application

The InvokeMethod method calls a method. It returns the following values:

  • In Server Script, it returns a string that contains the result of the method.
  • In Browser Script, it returns a Boolean value.

For more information, see About Specialized and Custom Methods.

Browser Script Format

theApplication().InvokeMethod(methodName, methArg1, methArg2, methArgN);

Table 34 describes the arguments for the InvokeMethod method.

Table 34. Arguments for the InvokeMethod Method
Argument
Description

methodName

The name of the method.

You can use the following arguments:

  • methArg1
  • methArg2
  • methArgN

One or more strings that contain arguments for the methodName argument.

Server Script Format

Application.InvokeMethod(methodName, methArg1, methArg2, methArgN);

The arguments you can use with this format are the same as the arguments described in Table 34.

Usage

The InvokeMethod method allows you to call a method on an application object that is made available directly through the Siebel application interface. For more information, see Caution About Using the InvokeMethod Method and LoadObjects Method for an Application.

Used With

Browser Script, COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

For an example, see Examples of Using the FindControl Method.

IsViewReadOnly Method for an Application

You can use the IsViewReadOnly method to determine if a view is read-only. This method returns the following information:

  • TRUE if the view is read-only
  • FALSE if the view is not read-only

If this method does not return TRUE or FALSE, then an error occurred. If this method does not return TRUE or FALSE, then your script must provide a handler.

Format

Application.InvokeMethod("IsViewReadOnly",viewName)

Table 35 describes the arguments for the IsViewReadOnly method.

Table 35. Arguments for the IsViewReadOnly Method
Argument
Description

viewName

The name of a view. You can include the name of this view in double quotes or in a variable that contains the name of the view.

Usage

You can set a view as read-only for a particular responsibility in the Responsibility Administration view. You can use the IsViewReadOnly method to determine if a view is read-only for the current responsibility before you attempt to edit a field.

Siebel CRM does not automatically set a button to read-only when that button resides in a view that is read-only. You can use the IsViewReadOnly method to set a button to read-only in a view where IsViewReadOnly returns TRUE.

Used With

To use this method, you can use an Application.InvokeMethod call with the following interfaces:

  • Browser Script
  • COM Data Control
  • COM Data Server
  • Siebel Java Data Bean
  • Mobile Web Client Automation Server
  • Server Script
Examples

The following example for Siebel eScript determines if the active view is read only:

function ShowViewROStatus()

{

var sActive = TheApplication().ActiveViewName();

if (TheApplication().InvokeMethod("IsViewReadOnly",sActive) == "TRUE")

TheApplication().RaiseErrorText(sActive + "is read only.");

else

TheApplication().RaiseErrorText(sActive + "is not read only.");

}

Language Method for an Application

The Language method returns the language code of the language that the active Siebel application is running. For example, ENU.

Format

Application.InvokeMethod("Language");

No arguments are available.

Used With

To use this method, you can use an Application.InvokeMethod call with Server Script.

Examples

The following example uses Siebel VB:

Dim curLang As String

curLang = TheApplication.InvokeMethod("Language")

The following example uses Siebel eScript:

var curLang;

curLang = TheApplication().InvokeMethod("Language");

LoadObjects Method for an Application

The LoadObjects method starts the COM Data Server. This method must be the first call to the COM Data Server. This method returns the following information:

  • If the COM Data Server starts successfully, then the LoadObjects method returns nothing.
  • If the COM Data Server does not start successfully, then the LoadObjects method returns an error.
Format

Application.LoadObjects(absoluteCFGfileName)

Table 36 describes the arguments for the LoadObjects method.

Table 36. Arguments for the LoadObjects Method
Argument
Description

absoluteCFGfileName

The path and name of the Siebel application configuration (CFG) file to open. For example:

C:\Siebel\8.1\Server\BIN\ENU

As an option, to identify the data source you can append the CFG file string with the data source, separated by a comma. For example:

C:\Siebel\8.1\Server\BIN\ENU\siebel.cfg,ServerDataSrc

If you do not specify the data source, then the LoadObjects method assumes the data source is local.

Usage

Prior to calling the LoadObjects method, you must modify the current folder to the Siebel\bin folder.

If you use the COM Data Server, then the COM client cannot create multiple connections to the COM Server. For example, a second attempt to call the LoadObjects method causes an error message that is similar to the following:

The object definition manager has already been initialized.

You must restart the COM client before you can make another successful connection. Use COM Data Control instead.

Used With

COM Data Server

Examples

The following example uses COM Data Server:

Private Sub LoadConfig_Click()
   Dim errCode As Integer
   LoadConfig.Enabled = False
   SiebelApplication.LoadObjects "C:\Siebel\8.1\Client_2\BIN\ENU\uagent.cfg", _
      errCode

   If errCode = 0 Then
      ConfigOK = 1
   End If

   Status.Text = SiebelApplication.GetLastErrText
End Sub

LoadUserAttributes Method for an Application

The LoadUserAttributes method loads a user profile to the session. This method does not return any information.

Format

LoadUserAttributes(row_id)

Table 37 describes the arguments for the LoadUserAttributes method.

Table 37. Arguments for the LoadUserAttributes Method
Argument
Description

row_id

The row ID of the user whose profile Siebel CRM must load.

Usage

To access the user profile, you can use the You profile from personalization rules, with the following exception: if the row ID is the row ID of the current user, then Siebel CRM loads the profile to the Me profile.

If you call this function with no argument, then it unloads the loaded user profile.

For information about user profiles, see Siebel Personalization Administration Guide.

Used With

Server Script

Examples

The following Siebel VB example loads a user profile to the session. The function is made available on the Siebel application object:

Function LoadUserProfile As Integer
TheApplication.InvokeMethod ("LoadUserAttributes","0-10N07")
End Function

The following Siebel VB example unloads the loaded user profile:

Function LoadUserProfile As Integer
TheApplication.InvokeMethod ("LoadUserAttributes", "")
End Function

Login Method for an Application

The Login method allows an external application to do the following:

  1. Log in to the COM Data Server, COM Data Control, or Siebel Java Data Bean.
  2. Access Siebel objects.

The Login method allows the end user to call the Siebel application without being prompted for a login and password. The Login method determines the privileges granted, and the role and responsibility of the end user for that session.

This method returns a string that contains the error code.

Format

Application.Login([connectString,] username, password)

Table 38 describes the arguments for the Login method.

Table 38. Arguments for the Login Method
Argument
Description

connectString

Connect string that uses a token.

username

Username for the login.

password

User password for the login.

Usage

Verify that the Siebel\bin folder is the current folder. To access Data Control, you must do the following work:

  • Make sure the default Data Source references the Siebel database that you must access. For more information, see Setting the Connect String.
  • In the Siebel application configuration (CFG) file, make sure the EnableOLEAutomation parameter is TRUE.
Used With

COM Data Control, COM Data Server, Mobile Web Client Automation Server, Siebel Java Data Bean

Examples

The connect string for COM Data Control uses a token. For example:

host = "Siebel://my_computer/SIEBEL/objsrvr/my_computer" lang = "ENU"

Most languages use quotes to enclose a text string, so you must use quotes in parentheses. For example:

  • To use COM Data Control in Visual Basic:

    m_dataBean.login("siebel.tcpip.none.none://gateway:gatewayport/enterpriseserver/SCCObjMgr", "username", "password");

  • To use COM Data Control in C++:

    Login("host=\"siebel://my_computer/SIEBEL/objsvr/my_computer\" lang = \"ENU\"","user","password");

The following example logs in to the Siebel Server and determines if errors exist:

   Call SiebelAppControl.Login("host=""siebel://gtwy/enterprise/ObjMgr""", "SADMIN", "SADMIN")
   
   //Check for errors
      If SiebelAppControl.GetLastErrCode <> 0 Then
         frmMain.txtStatus.Text = SiebelAppControl.GetLasErrText
      Else
         frmMain.txtStatus.Text = "Connected successfully..."
      End If

The following is a Siebel Java Data Bean example that logs in to a Siebel Server and then logs off:

import com.siebel.data.*;
import com.siebel.data.SiebelException;

public class JDBLoginLogoffDemo
{
   private SiebelDataBean m_dataBean = null;
   public static void main(String[] args)
   {
      JDBLoginLogoffDemo demo = new JDBLoginLogoffDemo();
   }

   public JDBLoginLogoffDemo()
   {
      try
      {

         // instantiate the Siebel Java Data Bean
         m_dataBean = new SiebelDataBean();

         // login to the Siebel Servers
         m_dataBean.login("siebel.tcpip.none.none://gateway:port/enterprise/
         object manager","userid","password");
         System.out.println("Logged in to the Siebel Server ");

         //perform function code

         //release the business object

         // logoff
         m_dataBean.logoff();
         System.out.println("Logged off the Siebel Server ");
      }

      catch (SiebelException e)
      {
         System.out.println(e.getErrorMessage());
      }
   }
}

LoginId Method for an Application

The LoginId method returns the login ID of the user who started the Siebel application.

Format

Application.LoginId

No arguments are available.

Usage

The login ID is the value of the ROW_ID column in the user login record in the S_USER table. You can use the login ID as a search specification.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

In this Siebel VB example in the BusComp_PreSetFieldValue event, the LoginId method determines if the user possesses the rights to modify a record:

Function BusComp_PreSetFieldValue (FieldName As String,
   FieldValue As String) As Integer
   Select Case FieldName
      Case "Account Status"
         if Me.GetFieldValue("Created By") <> _
            TheApplication.LoginId then
            TheApplication.RaiseErrorText("You cannot modify Account Status " & _
            "because you did not create the record.")
         end if
   End Select
   BusComp_PreSetFieldValue = ContinueOperation
End Function

LoginName Method for an Application

The LoginName method returns the login name of the user who started the Siebel application. This login name is the name that the user types in the login dialog box. For more information, see Login Method for an Application.

Format

Application.LoginName

No arguments are available.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

For examples, see ExecuteQuery Method for a Business Component and TheApplication Method.

Logoff Method for an Application

The Logoff method disconnects the Siebel client from the Siebel Server. This method does not return any information.

Format

Application.Logoff

No arguments are available.

Usage

For clients that include a user interface, the Logoff method removes every window except for the topmost window. Logoff also removes every object, except for the topmost object, on the Siebel client and Siebel Server.

If you remove the main object, then Siebel CRM automatically calls the Logoff method.

Used With

COM Data Control, Siebel Java Data Bean, Mobile Web Client Automation Server

LookupMessage Method for an Application

The LookupMessage method returns message text for a key. It returns this information in the current language.

Format

Application.LookupMessage (category, key, [arg1], [arg2],...., [argN])

Table 39 describes the arguments for the LookupMessage method.

Table 39. Arguments for the LookupMessage Method
Argument
Description

category

Name of the Message Category object that is the parent of the Key value. You can define this value in Siebel Tools.

key

Name of the Message object whose text contains the value that Siebel CRM must format. You can define this value in Siebel Tools.

Other arguments:

  • arg1
  • arg2
  • argN

If the error message contains a substitution argument, such as %1, then Siebel CRM uses these optional arguments to format the error message.

Usage

Useful for retrieving locale specific custom error messages.

Used With

Server Script

Examples

The following Siebel eScript example returns the following text:

Enter Account Title before stepping off.

To test this code in the User Defined Errors message category, create a new record with the following text:

Enter %1 before stepping off.

Siebel CRM uses the Account Title parameter to substitute the %1 variable:

var sVal = TheApplication().LookupMessage("User Defined Errors", "Test", "Account Title");

LookupValue Method for an Application

If all of the following items are true, then the LookupValue method locates a row in the S_LST_OF_VAL table:

  • The value in the TYPE column matches the value in the type argument.
  • The value in the CODE column matches the value in the lang_ind_code argument.
  • The value in the LANG_ID column matches the language code of the currently active language.

You can use this method to get the translation of the untranslated value in the LOV to the language that is currently active.

The LookupValue method returns a string that contains the display value from the VAL column for the row. If it does not find the display value, then it returns the language independent code as the value.

Format

val = Application.InvokeMethod("LookupValue", type, lang_ind_cd)

Table 40 describes the arguments for the LookupValue method.

Table 40. Arguments for the LookupValue Method
Argument
Description

type

The type that is specified in the List of Values administration view.

lang_ind_cd

Value for the language independent code that is specified in the List of Values administration view.

Used With

To use the LookupValue method, you can use an Application.InvokeMethod call with the following interfaces:

  • COM Data Control
  • Siebel Java Data Bean
  • Mobile Web Client Automation Server
  • Server Script
Examples

The following example is in Siebel eScript:

var LOVText = TheApplication().InvokeMethod("LookupValue","SR_AREA","Network");

Name Method for an Application

The Name method returns the name of the Siebel application.

Format

Application.Name

No arguments are available.

Used With

Browser Script, Web Client Automation Server

NewPropertySet Method for an Application

The NewPropertySet method creates a new property set. It returns a property set.

Format

Application.NewPropertySet

No arguments are available.

Usage

You can use the NewPropertySet method to create input and output arguments for a business service.

If you use the NewPropertySet method on an existing PropertySet object, then old references to this PropertySet are lost. If you reuse a PropertySet, then use the Reset method on this PropertySet.

Used With

Browser Script, COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script, Web Client Automation Server

Examples

This example creates a new property set. It uses Browser Script:

function Applet_PreInvokeMethod (name, inputPropSet)
{
   if (name == "MyCustomMethod")
   {
      var oBS;
      var inpPS;
      var outPS;
      inpPS = theApplication().NewPropertySet();
      outPS = theApplication().NewPropertySet();
      oBS = theApplication().GetService("New Value Business Service");
      outPS = oBS.InvokeMethod("New Value Method", inpPS);
      inpPS = null;
      outPS = null;
      oBS = null;
      return ("CancelOperation");
   }

   else
   {
      return ("ContinueOperation");
   }
}

The following example is for the Component Object Model (COM):

Dim oBS As SiebelService
Dim inpPS As SiebelPropertySet
Dim outPS As SiebelPropertySet
Dim errCode as integer

Set inpPS = SiebelApplication.NewPropertySet(errCode)
Set outPS = SiebelApplication.NewPropertySet(errCode)
Set oBS = SiebelApplication.GetService("New Value Business Service", errCode)
oBS.InvokeMethod "New Value Method", inpPS, outPS, errCode
Set inpPS = Nothing
Set outPS = Nothing
Set oBS = Nothing

The following example is in Siebel eScript:

function WebApplet_PreInvokeMethod (MethodName)
{
   if (MethodName == "MyCustomMethod")
   {
      var oBS;
      var inpPS;
      var outPS;
      inpPS = TheApplication().NewPropertySet();
      outPS = TheApplication().NewPropertySet();
      oBS = TheApplication().GetService("New Value Business Service");
      oBS.InvokeMethod("New Value Method", inpPS, outPS);
      inpPS = null;
      outPS = null;
      oBS = null;
      return (CancelOperation);
   }

   else
   {
      return (ContinueOperation);
   }

}

The following example is in Siebel VB:

Function WebApplet_PreInvokeMethod (MethodName As String) As Integer
   If MethodName = "MyCustomMethod" Then
      Dim oBS As Service
      Dim inpPS As PropertySet
      Dim outPS As PropertySet
      Set inpPS = TheApplication.NewPropertySet
      Set outPS = TheApplication.NewPropertySet
      Set oBS = TheApplication.GetService("New Value Business Service")
      oBS.InvokeMethod "New Value Method", inpPS, outPS
      Set inpPS = Nothing
      Set outPS = Nothing
      Set oBS = Nothing
      WebApplet_PreInvokeMethod = CancelOperation
   Else
      WebApplet_PreInvokeMethod = ContinueOperation
   End If

End Function

PositionId Method for an Application

The PositionId method returns the position ID of the user position. This position ID is the ROW_ID from the S_POSTN table. Siebel CRM sets this value by default when the Siebel application starts. To modify this value, the user can use the Edit menu, and then the Change Position menu item.

Format

Application.PositionId

No arguments are available.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

PositionName Method for an Application

The PositionName method returns the name of the current user position. Siebel CRM sets this value by default when it starts the Siebel application.

Format

Application.PositionName

No arguments are available.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

The following Siebel VB example determines the position of a user who is attempting to modify the sales stage. If the position does not allow this modification, then this code prevents the modification:

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

Dim sPosName As String sMsgText As String
Select Case FieldName
   Case "Sales Stage"
      If FieldValue = "Approved" Then
         ' Do not allow the sales cycle to be modified to
         ' this value if the User is not a manager or VP.
         sPosName = TheApplication.PositionName
         If NOT ((sPosName="Manager") OR (sPosName="VP"))Then
            TheApplication.RaiseErrorText("Only a Manager or Vice President can
            approve a Pipeline Item. Please notify your Manager that you _
            want to have this Pipeline Item approved.")
         End If
   BusComp_PreSetFieldValue = ContinueOperation
End Select

End Function

RaiseError Method for an Application

The RaiseError method sends a scripting error message to the browser. The error code is a standard number.

To determine the error text, Siebel CRM uses the key to look up the current language from the User-Defined Errors category. To define these errors in Siebel Tools, you can use the Message Category object. You can use the optional arguments to format the string if it contains a substitution argument, such as %1 or %2. This method does not return any information.

Format

Application.RaiseError(key, [arg1], [arg2],...., [argN])

The arguments you can use in this format are the same as the arguments that are described in Table 39 except the RaiseError Method does not include a category argument.

Usage for the RaiseError Method

The RaiseError method causes Siebel CRM to terminate the script and send a notification to the browser. Therefore, you are not required to use CancelOperation after you use the RaiseError method. For more information, see Caution About Using the Cancel Operation Event Handler.

The RaiseError method and the RaiseErrorText method create a Server Script exception. If you use error handling in your script, then the error handling can suppress RaiseError and RaiseErrorText functionality.

If you use On Error Goto error handling in Siebel VB, and if you use the RaiseError method or the result from the RaiseErrorText method, then Siebel CRM transfers the script run to the error handler. If you use On Error Resume Next error handling, then Siebel CRM suppresses the RaiseError method and the RaiseErrorText method.

CAUTION:  Be careful if you use RaiseError because it cancels operations. For example, if you use it in the BusComp_PreWriteRecord event, then the user or code cannot step off the current record until Siebel CRM addresses the condition that causes the call to the RaiseError method.

Used With

Server Script

Examples

In the following Siebel eScript example, the RaiseError method results in Siebel CRM raising a scripting exception and transferring control to the Catch statement. To display the error message, you must use the Throw statement:

function BusComp_PreDeleteRecord ()
{
   try {
      var status = this.GetFieldValue("Account Status");
   
      if (status == "Gold") {
         TheApplication().RaiseError(user defined error name);
      }
      else {
         return (ContinueOperation);
      }
   }
   catch (e) {
      throw e;
   }

}

In the following Siebel eScript example, if the user deletes an opportunity that includes the Pipeline revenue class, then Siebel CRM sends an error message:

function BusComp_PreDeleteRecord ()
{
   try
   {
      var revClass = this.GetFieldValue("Primary Revenue Class");
      if (revClass == "1-Pipeline")
      {
         TheApplication().RaiseError("user-defined test error1", "PreDelete",
         "RaiseError Method" );
      }

      else
      {
      return (ContinueOperation);
      }

   }
   catch (e)
   {
      throw e;
   }

}

Siebel CRM sends the following error message:

This user-defined test error is used in PreDelete, as an example for RaiseError Method

Note the following key:

user-defined test error1

This key is predefined as the following:

This user-defined test error is used in %1, as an example for %2.

When the script runs, Siebel CRM does the following:

  • Substitutes PreDelete for %1
  • Substitutes Raise Error Method for %2

RaiseErrorText Method for an Application

The RaiseErrorText method sends a scripting error message to the browser. This method does not return any information.

Format

Application.RaiseErrorText(value, [arg1], [arg2],...., [argN])

Table 41 describes the arguments for the RaiseErrorText method.

Table 41. Arguments for the RaiseErrorText Method
Argument
Description

value

The error text message.

Other arguments:

  • arg1
  • arg2
  • argN

If the error message contains a substitution argument, such as %1, then Siebel CRM uses these optional arguments to format the error message.

Usage

Usage for the RaiseErrorText method is very similar to usage for the RaiseError method. For more information, see Usage for the RaiseError Method.

Used With

Server Script

Examples

In the following Siebel eScript example, the RaiseErrorText method causes Siebel CRM to raise a scripting exception and then transfer control to the Catch statement. To display the error message, you must use the Throw statement.

function BusComp_PreDeleteRecord ()
{
   try {
      var status = this.GetFieldValue("Account Status");
   
      if (status == "Gold") {
         TheApplication().RaiseErrorText("Unable to delete Gold Account");
      }
      else {
         return (ContinueOperation);
      }
   }
   catch (e) {
      throw e;
   }

}

In the following Siebel eScript example, if the user deletes an opportunity that includes Pipeline as the revenue class, then Siebel CRM sends an error:

function BusComp_PreDeleteRecord ()
{
   try
   {
      var revClass = this.GetFieldValue("Primary Revenue Class");
      if (revClass == "1-Pipeline")
      {
         TheApplication().RaiseErrorText("Exception occurred in %1. Unable to
         delete Opportunity with %2 revenue class.", "PreDeleteRecord", revClass);
      }
      else
      {
         return (ContinueOperation);
      }

   }
   catch (e)
   {
      throw e;
   }
}

SetPositionId Method for an Application

The SetPositionId method sets the active position to a Position Id. This method returns a Boolean value that indicates if Siebel CRM successfully completed the operation.

Format

Application.SetPositionId(positionId)

Table 42 describes the arguments for the SetPositionId method.

Table 42. Arguments for the SetPositionId Method
Argument
Description

positionId

A string that contains the Position Id.

Usage

The positionId argument must contain the Position Id that is associated with the user who is currently logged in to the Siebel application.

Used With

COM Data Server, COM Data Control, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

SetPositionName Method for an Application

The SetPositionName method sets the active position to a position name. The method returns a Boolean value that indicates if the method succeeded.

Format

Application.SetPositionName(positionName)

Table 43 describes the arguments for the SetPositionName method.

Table 43. Arguments for the SetPositionName Method
Argument
Description

positionName

A string that contains the name of the position.

Usage

The positionName argument must contain the Position name that is associated with the user who is currently logged in to the Siebel application.

Used With

COM Data Server, COM Data Control, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

SetProfileAttr Method for an Application

Personalization uses the SetProfileAttr method to set a value for an attribute in a user profile. This method does not return any information.

Format

Application.SetProfileAttr(name, value)

Table 44 describes the arguments for the SetProfileAttr method.

Table 44. Arguments for the SetProfileAttr Method
Argument
Description

name

A string that contains the name of the attribute.

value

The value of the attribute.

Usage

The SetProfileAttr method sets the value of the value argument to an attribute in the user profile that the name argument contains. Siebel CRM does the following work:

  • If this attribute already exists, then Siebel CRM updates the corresponding persistent profile attribute in the Siebel application. This value is defined in the Personalization Profile business component.
  • If the profile attribute does not exist in the list of persistent profile attributes, then Siebel CRM creates it as a dynamic profile attribute. It does not include quotation marks at the beginning or end of the name.
  • If you use the SetProfileAttr method in Browser Script, then Siebel CRM performs a round trip to the Siebel Server and back to the browser each time it uses this method. This processing creates a performance overhead.

For more information about user profile attributes, see Siebel Applications Administration Guide.

Using System Fields with the SetProfileAttr Method

You cannot use the SetProfileAttr method with a system field. These fields are not explicitly defined in the Personalization Profile business component. You cannot use the SetProfileAttr method with the Id field because attempting to modify the ROW_ID column of a table creates an error. For more information about system fields, see Configuring Siebel Business Applications.

Personalization uses the GetProfileAttr method. Siebel CRM does not explicitly define system fields in the Personalization Profile business component, so you cannot use this method with a system field, except for the Id field. For more information, see Siebel Personalization Administration Guide.

Used With

Browser Script, COM Data Control, COM Data Server, Server Script, Siebel Java Data Bean, Mobile Web Client Automation Server

Examples

The following example is in Browser Script:

function Applet_PreInvokeMethod (name, inputPropSet)

{
   if (name == "hobbyReq") {
      var hobby = theApplication().GetProfileAttr("Hobby");

      
      if (hobby == "") {
         hobby = prompt("Please enter your favorite hobby");
         theApplication().SetProfileAttr("Hobby", hobby);
      }
      return ("CancelOperation");
   }
   else
      return ("ContinueOperation");
}

This following examples exchange information between an applet Server Script and an applet Browser Script:

  • In the applet Server Script, Siebel CRM uses the SetProfileAttr method to set a customer profile attribute named MyProAttr to Hello World.
  • In the applet Browser Script, you can use the GetProfileAttr method to return the profile attribute.

The following example is in Siebel eScript:

function WebApplet_PreInvokeMethod (MethodName)
{

   if (MethodName == "MyCustomMethod") {

      TheApplication().SetProfileAttr("MyProAttr", "Hello World Siebel eScript");
      return (CancelOperation);

   }
   return (ContinueOperation);

}

The following example is in Siebel VB:

Function WebApplet_PreInvokeMethod (MethodName As String) As Integer

If MethodName = "MyCustomMethod" Then

   TheApplication.SetProfileAttr "MyProAttr", "Hello World VB"
   WebApplet_PreInvokeMethod = CancelOperation
Else
   WebApplet_PreInvokeMethod = ContinueOperation
End If

End Function

SetSharedGlobal Method for an Application

The SetSharedGlobal method sets a shared global variable that your code can access with the GetSharedGlobal method. The SetSharedGlobal method does not return any information.

Format

Application.SetSharedGlobal(varName, value)

Table 45 describes the arguments for the SetSharedGlobal method.

Table 45. Arguments for the SetSharedGlobal Method
Argument
Description

varName

String variable or literal that contains the name of the shared global variable that Siebel CRM must set.

value

String variable or literal that contains the value of the shared global variable.

Used With

COM Data Control, COM Data Server, Mobile Web Client Automation Server, Server Script

Examples

The following example is for the Component Object Model (COM):

comVar = SiebelApplication.GetSharedGlobal("myVar", errCode)
SiebelApplication.SetSharedGlobal "myVar", "BLAH", errCode

The following example is in Siebel VB:

TheApplication.SetSharedGlobal "myVar", "FOO"
myVar = TheApplication.GetSharedGlobal("myVar")

The remaining examples for using the SetSharedGlobal method are the same as the examples for using the GetSharedGlobal method. For more information, see Example of Using the GetSharedGlobal Method.

ShowModalDialog Method for an Application

The ShowModalDialog method allows you to display a dialog box with the cursor in the default state. This application object method calls the equivalent object method in Microsoft Windows. This method returns the value of the returnValue property. The window of the document specified in the url argument sets this property.

Format

theApplication().ShowModalDialog (url[, argin][, options])

Table 46 describes the arguments for the ShowModalDialog method.

Table 46. Arguments for the ShowModalDialog Method
Argument
Description

url

The URL of the document that Siebel CRM finished loading and displaying.

argin

Passes arguments to use if Siebel CRM displays the document. This argument can be a value of any type, including an array of values.

For more information, see the window.dialogArguments property of the object in the Document Object Model. For example:

  • See the window.showModalDialog property at http://developer.mozilla.org.
  • See the showModalDialog method at http://msdn.microsoft.com.

options

String that specifies the attributes for the dialog box. For more information, see Values for the Options Argument.

Values for the Options Argument

Table 47 describes values you can use for the options argument of the ShowModalDialog method. You must use a semicolon to separate these values.

Table 47. Values for the Options Argument of the ShowModalDialog Method
Option
Description

dialogHeight

Sets the height of the dialog box.

You must use an integer or floating-point number followed by one of the following items:

  • An absolute units designator. For example, cm, mm, in, pt, pc, or px.
  • A relative units designator. For em or ex. The default value is em.

For consistent results, specify the dialogHeight and dialogWidth in pixels. The minimum height is 100 pixels.

dialogLeft

Sets the left position of the dialog box relative to the upper-left corner of the desktop.

dialogTop

Sets the top position of the dialog box relative to the upper-left corner of the desktop.

dialogWidth

Sets the width of the dialog box.

center

Sets centering for the dialog box. You can use one of the following values:

  • yes
  • no
  • 1
  • 0
  • on
  • off

The default value is yes.

dialogHide

Specifies how to hide the dialog box if the user prints or uses print preview. This option is available only if the user opens the dialog box from a trusted application.

You can use the same values that you use with the center option. The default value is no.

edge

Specifies the edge style of the dialog box. You can use one of the following values:

  • sunken
  • raised

The default value is raised.

help

Specifies how to display the dialog box with the context-sensitive Help icon. You can use the same values that you use with the center option. The default value is yes.

resizable

Specifies if the dialog box dimensions are fixed.

You can use the same values that you use with the center option. The default value is no.

scroll

Specifies if the dialog box displays scrollbars.

You can use the same values that you use with the center option. The default value is yes.

status

Specifies how the dialog box displays a status bar.

You can use the same values that you use with the center option. The default value is one of the following:

  • yes for an untrusted dialog box
  • no for a trusted dialog box

unadorned

Specifies how the dialog box displays the border window chrome. This feature is available only if the user opens the dialog box from a trusted application. A trusted application is an application that includes a trust certificate.

You can use the same values that you use with the center option. The default value is no.

Used With

Browser Script

Examples

This example uses Browser Script to display a dialog box that includes a URL:

function Applet_Load ()
{
var sOptions="dialogHeight: 1000px;edge:sunken;resizable;yes";
theApplication().ShowModalDialog("http://www.yahoo.com", "", sOptions)
}

SWEAlert Method for an Application

The SWEAlert method displays a modal dialog box that includes a message. This method does not return any information.

Format

theApplication().SWEAlert(message)

Usage

Use the SWEAlert method instead of alert. Note the following:

  • If you use the SWEAlert method, then Siebel CRM does not send the parent applet to the background.
  • If you use alert, then Siebel CRM sends pop-up applets to the background. MVGs and pick applets are examples of pop-up applets. If a browser event sends a JavaScript alert, then Siebel CRM hides the pop-up applet.
Used With

Browser Script

Examples

The following Browser Script example displays a status message:

function BusComp_PreSetFieldValue (fieldName, value) {

   if (fieldName == "Account Status") {
      var cVolume = this.GetFieldValue("Current Volume");
      if ((value == "Inactive") && (cVolume > 0)) {
         theApplication().SWEAlert("Unable to inactivate an account that has a
         current volume greater than 0");

         return ("CancelOperation");
      }
      else
         return ("ContinueOperation");
   }
   else
      return ("ContinueOperation");
}

Trace Method for an Application

The Trace method appends a message to the trace file. Trace helps to debug an SQL query and to monitor how Siebel CRM allocates objects. This method does not return any information.

This tracing is not the same as the tracing that you can activate in the Siebel application configuration (CFG) file. For more information, see Tracing a Script.

It is recommended that you do not use the Trace method or the TraceOn method in a production environment. For more information, see TraceOn Method for an Application.

Format

Application.Trace(message)

Table 48 describes the arguments for the Trace method.

Table 48. Arguments for the Trace Method
Argument
Description

message

String variable or literal that contains message text that Siebel CRM appends to the trace file.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

The following example is for COM Data Server:

Private Sub TraceOn_Click()
   Dim ErrCode As Integer
   SiebelApplication.TraceOn "c:\temp\trace.txt", "allocation", _
      "all",       ErrCode
   If (ErrCode = 0) Then SiebelApplication.TraceOn
      "c:\temp\trace.txt",      "SQL", "",ErrCode   
   If (ErrCode = 0) Then SiebelApplication.Trace
      "Start of Tracing!",
      ErrCode
End Sub

The following example is in Siebel VB:

Sub Button2_Click
   TheApplication.TraceOn "C:\temp\trace.txt", "allocation",   "all"
   TheApplication.TraceOn "C:\temp\trace.txt", "sql", ""
   TheApplication.Trace "start of tracing!"
End Sub

Example Trace Output

The following is example output of an Allocation trace section:

03/05/98,17:27:47,START,4.0.4 [1425_P3] ENU
03/05/98,17:27:47,ALLOC,1,BusObject,Account,Basic
03/05/98,17:27:48,ALLOC,2,BusComp,Account,Basic
03/05/98,17:27:48,RELEASE,1
03/05/98,17:27:48,RELEASE,2

The following is example output of an SQL trace section:

01/22/98,21:03:49,START,4.0.2 [1416] ENU
01/22/98,21:04:02,COMMENT,Start of Tracing!
01/22/98,21:04:10,SQLSTMT,1,SELECT,"SELECT
   T1.ROW_ID,
   T1.MODIFICATION_NUM,
   T1.CREATED_BY,
   T1.LAST_UPD_BY,
   T1.CREATED,
   T1.LAST_UPD,
   T1.CONFLICT_ID,
   T1.NAME,      
   T1.DESC_TEXT,
   T1.PRIV_FLG,
   T1.QUERY_STRING
FROM
   DEV32.S_APP_QUERY T1
WHERE
   (T1.CREATED_BY = :1 OR T1.PRIV_FLG = :2) AND
   ((T1.NAME LIKE :3 OR T1.NAME LIKE :4 OR T1.NAME LIKE :5 OR
      T1.NAME LIKE :6) AND UPPER(T1.NAME) = UPPER(:7))
   ORDER BY
      T1.NAME, T1.DESC_TEXT"
01/22/98,21:04:10,SQLBIND,1,1,1-6NF
01/22/98,21:04:10,SQLBIND,1,2,N
01/22/98,21:04:10,SQLBIND,1,3,ac%
01/22/98,21:04:10,SQLBIND,1,4,Ac%
01/22/98,21:04:10,SQLBIND,1,5,aC%
01/22/98,21:04:10,SQLBIND,1,6,AC%
01/22/98,21:04:10,SQLBIND,1,7,Account

Related Topics

For more information, see the following topics:

TraceOff Method for an Application

The TraceOff method turns off tracing that the TraceOn method starts. This method does not return any information.

Format

Application.TraceOff

No arguments are available.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

This following example in Siebel VB sets the value in the Sales Stage field to the first value in the drop-down list for the field. It uses tracing to track the result:

Sub BusComp_NewRecord
   TheApplication.TraceOn "C:\lvpick.doc", "SQL", ""
   Dim oBC as BusComp
   set oBC = me.GetPickListBusComp("Sales Stage")

   With oBC
      .SetViewMode AllView
      .ActivateField "Sales Stage Order"
      .ClearToQuery
      .SetSortSpec "Sales Stage Order"
      .ExecuteQuery ForwardOnly
      if .FirstRecord then
         .Pick
      end if
   End With

   set oBC = Nothing

   TheApplication.TraceOff

End Sub

TraceOn Method for an Application

The TraceOn method turns on tracing for allocations and deallocations of Siebel objects and SQL statements that Siebel CRM creates. This method does not return any information.

Format

Application.TraceOn(filename, type, selection)

Table 49 describes the arguments for the TraceOn method.

Table 49. Arguments for the TraceOn Method
Argument
Description

filename

Output filename for trace messages. If you do not use this argument, then Siebel CRM logs tracing information to the Object Manager log file. For more information, see Filename Argument of the TraceOn Method.

type

The type of tracing to start. You can use the following values:

  • Allocation. Traces allocations and deallocations of Siebel objects. This feature is useful if you suspect a memory leak exists in your code.
  • SQL. Traces SQL statements that the Siebel application creates.

selection

Identifies the Siebel objects that Siebel CRM must trace for the Allocation trace type. This argument is "" if the trace type is SQL:

  • Script. Traces Siebel VB and Siebel eScript objects.
  • OLE. Traces allocations for data server or automation server programs.
  • All. Traces all objects that Siebel CRM creates as a result of scripting. This value does not trace Siebel objects that are defined through Siebel Tools.

Filename Argument of the TraceOn Method

You can use the following values for the filename argument:

  • $p. Substitutes the process Id for the filename.
  • $t. Substitutes the thread Id for the file name.

For example:

TheApplication().TraceOn("C:\\temp\\trace_$p_$t.txt", "Allocation", "All");

This code causes Siebel CRM to log trace files to the trace_1496_1412.txt file in the C:\temp\trace folder.

To make sure the filename argument is unique, you must place a separator between the $p and $t values. For example, assume you do not use a separator and the following items are true:

  • The process id for user A is 1 and the thread id is 12.
  • The process id for user B is 11 and the thread id is 2.

In this situation, the file name is trace_112.txt for user A and for user B, so Siebel CRM logs trace information for each user to the same file.

If you add a separator between the process id and the thread id, then the file names are unique and Siebel CRM logs trace information to a separate file for each user. For example:

  • trace_1_12.txt
  • trace_11_2.txt
Usage

To turn off tracing, you must call the TraceOff method. If you attempt to call the TraceOn method with a different filename without first calling TraceOff, then Siebel CRM writes trace information to the new trace file name. The old file remains open and is locked. You can issue multiple TraceOn statements to the same trace file.

It is recommended that you do not use the Trace method or the TraceOn method in a production environment. For more information, see Trace Method for an Application.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

The following example is for COM Data Server:

Private Sub TraceOn_Click()
   Dim ErrCode As Integer
   SiebelApplication.TraceOn "c:\temp\trace.txt", "allocation",
      "all",       ErrCode
   If (ErrCode = 0) Then SiebelApplication.TraceOn
      "c:\temp\trace.txt",      "SQL", "",ErrCode   
   If (ErrCode = 0) Then SiebelApplication.Trace
      "Start of Tracing!",
      ErrCode
End Sub

The following example is in Siebel eScript:

function BusComp_PreSetFieldValue (FieldName, FieldValue)

{
TheApplication().TraceOn("C:\\temp\\trace.txt", "Allocation", "All");
TheApplication().TraceOn("C:\\temp\\trace.txt", "SQL", "");
TheApplication().Trace("start tracing!");

return (ContinueOperation);
}

The following example is in Siebel VB:

Sub Button2_Click
   TheApplication.TraceOn "C:\temp\trace.txt", "allocation",
      "all"
   TheApplication.TraceOn "C:\temp\trace.txt", "sql", ""
   TheApplication.Trace "start of tracing!"
End Sub

For example trace output, see Example Trace Output.

The following examples use Trace, Traceoff, and TraceOn methods to create a trace file with SQL statements issues by the scripting query.

The following example is in Siebel eScript:

function BusComp_NewRecord ()
{
   TheApplication().TraceOn("C:\\trace_output.txt", "SQL", "");
   TheApplication().Trace("Start of tracing!");
   var oBC = this.GetPickListBusComp("Sales Stage");

   with (oBC)
   {
      SetViewMode(AllView);
      ClearToQuery();
      SetSortSpec("Sales Stage Order(ASCENDING)");
      ExecuteQuery(ForwardOnly);
      if (FirstRecord())
      {
         Pick();
      }
   }

   oBC = null;
   TheApplication().Trace("End of tracing!");
   TheApplication().TraceOff();
}

The following example is in Siebel VB:

Sub BusComp_NewRecord

   TheApplication.TraceOn "C:\trace_output.txt", "SQL", ""
   TheApplication.Trace "Start of tracing!"
   Dim oBC as BusComp
   Set oBC = Me.GetPickListBusComp("Sales Stage")

   With oBC
      .SetViewMode AllView
      .ClearToQuery
      .SetSortSpec "Sales Stage Order(ASCENDING)"
      .ExecuteQuery ForwardOnly
      If .FirstRecord Then
         .Pick
      End If
   End With

   Set oBC = Nothing
   TheApplication.Trace "End of tracing!"
   TheApplication.TraceOff
End Sub

Related Topics

For more information, see the following topics:

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