[Progress News] [Progress OpenEdge ABL] Introduction to Service Call Out in Corticon.js V2.0

Status
Not open for further replies.
T

Thierry Ciot

Guest
The Corticon.js V2.0 release introduces a new feature called Service Call Out.

What is It?​


Simply put it, a service callout (or SCO for short) is an execution step in a decision service flow that invokes custom JavaScript logic.

Here is a simple ruleflow example where the SCO Call is executing after a specific rulesheet (“Before SCO Call”):



Note: The service call out can happen anywhere in the ruleflow. It could be the first or last step of the entire ruleflow.

What Can It Do?​


As custom JavaScript code, the service callout can practically do anything. It has access to the full data payload at the step in which it is invoked. This is the full input data payload as well as all the modifications to it from rules that have executed thus far.

We provide an API to facilitate reading from the payload as well as writing to it. This can be leveraged to enrich the payload with additional data. It is useful for use cases where it is not desirable to pass the data in the input payload in the first place, i.e. when services will only use some of the data in specific execution paths.

Another way to put this is that some services will need to conditionally access additional data based on conditions computed in the decision service. For example, when computing an offer for a solar system installation, you will need access to various configuration pricing data. Instead of passing all the data for all possible configurations for all the regions, it may be more appropriate to have an SCO request the subset of the data the decision service really needs at that point in the execution.

Of course, the SCO can persist portion of the payload to an external data source.

Example usages could be to access data via a REST service or a Database call. Or, it could be to provide some complex financial calculation.

For more information on the API, check the online documentation here.

Getting Started​


To get started, we have provided several samples at corticon.js-samples/ServiceCallOut at master · corticon/corticon.js-samples.

Here is a brief run down of the first ones you need to focus on to get started smoothly:

HelloWorld is the simplest SCO. It is at corticon.js-samples/ServiceCallOut/HelloWorld at master · corticon/corticon.js-samples.

It shows the basic mechanics of an SCO.

Next, you should look at the basic sample to update attributes corticon.js-samples/ServiceCallOut/UpdateEntityAttributes at master · corticon/corticon.js-samples.

It is particularly useful to understand how to create non-primitive types like Decimals, DateTimes and Dates. Attributes using primitive types like strings and integers can be updated with JavaScript Strings and JavaScript Numbers respectively.

If your use case requires creating additional entities and relations (for example adding child entities to a parent entity), check this sample: corticon.js-samples/ServiceCallOut/CreateAssociation at master · corticon/corticon.js-samples.

When you need to pass configurable data, you can leverage the access to the configuration properties as illustrated in this sample: corticon.js-samples/ServiceCallOut/AccessConfigurationProperties at master · corticon/corticon.js-samples.

Most likely you will need to access (read or write) data from external data sources. In this case, you will need to understand how to do asynchronous operations. We will cover considerations for doing asynchronous operations in a separate blog but in the meantime, check this sample to get started: corticon.js-samples/ServiceCallOut/BasicAsyncOperation at master · corticon/corticon.js-samples.

There are several additional samples not described here. Check them out at: corticon.js-samples/ServiceCallOut at master · corticon/corticon.js-samples.

Conclusion​


The support for either passing all the data in or conditionally accessing data on an as-needed basis at any point in the flow provides maximum flexibility in architecting and designing optimum decision services.

Writing to a data source at any point in the decision service flow also provides architecture flexibility.

Find out here how Corticon as a no-code/low-code environment can help increase your productivity and deliver your solutions faster.

And you can enroll in a free training for Corticon.js here.

Continue reading...
 
Status
Not open for further replies.
Top