Skip navigation

For some more complex tasks in Oracle ABCS you might need to resort to coding.

 

In the example video below you'll see such an example.

In the application we want to check if an event that a person wants to register for has open spaces.

If there are open spaces we just need to process the registration and save the details.

If however there isn't open space we want to notify the person that they are on a wait list and perform a bit of a different processing adding an indicator to our data that the person is on the wait list for the event.

 

To achieve this, we are going to need to:

  • Traverse a relation ship between to related custom object
  • Execute a query on a custom object with a specific condition
  • Analyze the values in the row that was returned
  • Conditionally navigate to one of two recipes flows

 

Here is a quick demo showing you how we did this:

And here is the code used in the sample:

 

require([

    'operation/js/api/Conditions',

    'operation/js/api/Operator'

], function (Conditions, Operator) {

    var lab = Abcs.Entities().findById('Lab');

    var id = lab.getProperty('id');

    //condition is to find a lab with the id that is in the page's drop down box

    var condition = Conditions.SIMPLE(id, Operator.EQUALS, $Person.getValue('ref2Combo_Box'));

    var operation = Abcs.Operations().read({

        entity: lab,

        condition: condition

    });

    //if query returned value we loop over the data and check the capacity and registration

    operation.perform().then(function (operationResult) {

        if (operationResult.isSuccess()) {

            operationResult.getData().forEach(function (oneRecord) {

                if ((oneRecord.Capacity - oneRecord.Registered) < 1) {

                    $Person.setValue('Waitlisted', true);

                    reject("error");

                } else

                {

                    resolve("ok");

                }

            });

        }

    }).catch(function (operationResult) {

        if (operationResult.isFailure()) {

            // Insert code you want to perform if fetching of records failed

            alert('didnt worked');

            reject("error");

        }

    });

});