Oracle CRM On Demand JavaScript API Developer's Guide > JavaScript API Reference >

Errors and Error Handling


For CRUD operations, the errors object specifies null or an array of objects in the following format:

{

fac : "SBL-ODU-MSG_NUMBER", // error code

msg : "MSG_TEXT" // error message

}

For example, for response.errors[0]:

{

fac : "SBL-ODU-00271",

msg : "Invalid value for the parameter:objectName."

}

Example Code of How to Deal with the Error Object

You must implement your own error handing in custom JavaScript code. As an example of how to deal with the error object, the following is a callback function that displays error codes and error messages from CRUD operations.

function callback(request,response){

var data = "data: ";

var status = response.status;

var error = "error: "

if (status == "OK")

error += status;

else

error += response.errors[0].fac + "\n" + response.errors[0].msg;

var dataObj = response.data;

if (dataObj != null)

data += "Id = " + response.getRowId() + ", Mod Id = " + response.getModId();

else

data += "Data is Null";

alert(data + "\n" + status + "\n" + error);

}

});

A guideline is to use the error code in error handling rather than the error message. This is recommended because the error code is language independent, but the error message is not. Code like the following only works in English:

if (response.errors[0].msg == "No records found")

CRUD Error Codes and Messages

Table 15 shows some error codes and messages that might be returned.

Table 15. Error Codes and Messages
Code
Message
Description

SBL-ODU-00251

The requested operation has encountered an error.

An internal configuration error occurred. This error is rare.

SBL-ODU-00271

Invalid value for the parameter: parameter_name.

The parameter for the CRUD operation specified a null or empty objectName parameter, a nonexistent objectName (for example, "Acount"), or a null or empty row ID.

SBL-ODU-57081

No records found.

An operation tried to read a nonexistent record.

SBL-DAT-00398

Field 'field_name' does not exist in definition for business component 'record_type'. Please ask your systems administrator to check your configuration.

An operation specified a nonexistent field name.

SBL-DAT-00498

'<field>field_name</field>' is a required field. Please enter a value for the field.

An operation did not specify a value for a field that is required.

SBL-ODS-50006

A record that contains identical values to the record you are trying to create already exists. If you would like to enter a new record, please ensure that the field values are unique.

An operation tried to create a record that already exists.

Oracle CRM On Demand JavaScript API Developer's Guide, Release 38 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Legal Notices.