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)

The following table describes the 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 the example of using the EnableExceptions method with Siebel ActiveX Data Control earlier in this topic, except that the script in this example 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