Handling SOAP Errors
You should always check that any SOAP API call was successful before using the results.
-
For calls to NSOA.record.<complex type>( [id] ), only check that an object was returned.
var category = new NSOA.record.oaCategory(); if( !category ) // An unexpected error has occurred! -
For all other calls you need to check that a result was returned and did not contain any errors.
This is a two step process:
-
First check that you have an array of responses.
if (!result || !result[0]) -
If OK, then check if you have an errors property and you have at least one error.
else if (result[0].errors !== null && result[0].errors.length > 0)
// example assuming readRequest has already been defined var result = NSOA.wsapi.read(readRequest); // Check for errors if (!result || !result[0]) { // An unexpected error has occurred! } else if (result[0].errors !== null && result[0].errors.length > 0) { // There are errors to handle! } else { // Process the response as expected } -
The errors property is an array of oaError objects.
See Code Samples for more examples.
oaError
An array of oaError objects is returned in the ReadResult and UpdateResult objects.
In this version, only the code property is available from user script.
|
Property |
Value |
|---|---|
|
attributes |
An array of additional attributes for this complex type. |
|
comment |
More Information for the error. |
|
text |
Short Message for the error. |
|
code |
Error code returned by the SOAP API. |
For the full list of errors, see Error Codes.
See also Error Handling.
Who Am I
You can get information about the currently signed in user by calling the NSOA.wsapi.whoami() function.
The NSOA.wsapi.whoami() function returns an oaUser object.
function test() {
var user = NSOA.wsapi.whoami();
NSOA.meta.alert( "User ID " + user.id + " saved this record");
}
oaUser
The oaUser object has more than 100 attributes defining user specific information. See User.
An oaUser object is returned by the NSOA.wsapi.whoami() function.