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 LookupMessage Method for an Application except that 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.

function BusComp_PreDeleteRecord ()
{
   try {
      var status = this.GetFieldValue("Account Status");
      if (status == "Gold") {
         TheApplication().RaiseError(user defined error name);
      } // end if (status == "Gold")
      else {
         return (ContinueOperation);
      } // end else
   } // end try
   catch (e) {
// Put here any logic that must be executed before displaying an error to user
   throw e;
   } // end catch
} // end function

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" );
      } // end if (revClass == "1-Pipeline")
      else {
         return (ContinueOperation);
      } // end else
   } // end try
   catch (e) {
// Put here any logic that must be executed before displaying an error to user
   throw e;
   } // end catch
} // end function

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 RaiseError Method for %2