JavaScript Extension Development API for Oracle Visual Builder Cloud Service - Classic Applications

Class: operation/js/api/OperationResult

Represents result returned from particular Operation.perform(..) method call.

Each Operation.perform(..) method call returns an instance of OperationResult. It either:

  • Provides returned data in case Operation performed correctly.
    It also can contain any other metadata which Business Object Provider decides to return. For example PaginationCursor can be available if the perfomed Operation has type Operation.Type.READ_MANY set and provider implemented capability to paginate through the records.
  • Provides error code, message and possibly any other additional error information in case Operation performed incorrectly.
To check the result of Operation.perform(..) call, you can use:

Version:
  • 17.1.1
Source:
See:

Classes

operation/js/api/OperationResult.Failure
operation/js/api/OperationResult.Success

Methods

(static) failure(message, codeopt, additionalInfoopt) → {operation/js/api/OperationResult.Failure}

stable API

Creates new instance of OperationResult.Failure result.

Parameters:
Name Type Attributes Description
message String

Message describing in detail why Operation.perform(..) method failed.

code Number <optional>

Error code for better identification of what type of error caused Operation.perform(..) method to fail.

additionalInfo Object <optional>

Additional information about the failure.

Version:
  • 17.1.1
Source:
Returns:
Type
operation/js/api/OperationResult.Failure
Examples

Creates an instance of OperationResult.Failure result with only message text set.

var error = OperationResult.failure('This is an example of error message.');

Creates an instance of OperationResult.Failure result with message text and error code set.

var error = OperationResult.failure('Not Found.', 404);

Creates an instance of OperationResult.Failure result with message text, error code and additional information set.

var error = OperationResult.failure('Not Found.', 404, {
    foo: 'You can include anything you want here',
    bar: {
        barbar: 'You can even structure additional information any way you need'
    }
});

(static) success(dataopt, paginationCursoropt, additionalInfoopt) → {operation/js/api/OperationResult.Success}

stable API

Creates new instance of OperationResult.Success result.

Parameters:
Name Type Attributes Description
data Object <optional>

REST data response.

paginationCursor operation/js/api/PaginationCursor <optional>

Metadata describing data pagination if it was requested.

additionalInfo Object <optional>

Additional information about the successful operation.

Version:
  • 17.1.1
Source:
Returns:
Type
operation/js/api/OperationResult.Success

isFailure() → {Boolean}

stable API

Checks whether this OperationResult is OperationResult.Failure or not.

Version:
  • 17.1.1
Source:
Returns:

true if this OperationResult is OperationResult.Failure, false otherwise

Type
Boolean
Example

Performs an existing Operation and check the result using OperationResult.isFailure() method.

var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var operation = Abcs.Operations().create({
    entity: employee,
    record: {
        firstName: 'Martin',
        lastName: 'Janicek',
        age: 28
    }
});

operation.perform().then(function(operationResult) {
    // Do something when your operation succeed
}).catch(function(operationResult) {
    if (operationResult.isFailure()) {
        // Insert code you want to perform if record creation failed
    }
});

isSuccess() → {Boolean}

stable API

Checks whether this OperationResult is OperationResult.Success or not.

Version:
  • 17.1.1
Source:
Returns:

true if this OperationResult is OperationResult.Success, false otherwise

Type
Boolean
Example

Performs an existing Operation and check the result using OperationResult.isSuccess() method.

var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var operation = Abcs.Operations().create({
    entity: employee,
    record: {
        firstName: 'Martin',
        lastName: 'Janicek',
        age: 28
    }
});

operation.perform().then(function(operationResult) {
     if (operationResult.isSuccess()) {
         // Insert code you want to perform after record being created
     }
});