logo

NJP

ServiceNow Decision Tables as a queryable Business Rules Management System

Import · Aug 08, 2022 · article

In this article I'll walk through leveraging Flow Designer, Integration Hub and Decision Tables to make ServiceNow act as a queryable Business Rules Management System. But not those business rules…

A Business Rules Management System according to the all-knowing Wikipedia is a software system used to define, deploy, execute, monitor and maintain the variety and complexity of decision logic that is used by operational systems within an organization or enterprise.

Basically, we're making a decision accessible to another system via an inbound API call to ServiceNow.

First we need to create the decision.

I've gone for something really simple as the decision.

It takes an integer and outputs whether is Equal to or over 100, or Under 100.

image

The next thing we need to build is the Flow Action that will send back the response to the calling endpoint.

Inputs we'll need are:

  • A Callback URL
  • The Answer from the decision
  • I'm also using the decision input because I'm just going to send back some text in the response.

image

Then we'll need a REST Step

Because this walkthrough is only showing the basics we'll define the connection inline with no authorization.

Set the Base URL with the input callbackURL data pill.

Set the HTTP Method to POST

image

For the Content, again just a basic object with the decision input and the answer.

image

Now to the Flow.

Our Flow Trigger will be "REST API Asynchronous"

This is an elegant no/low code alternative to a Scripted REST API.

Set the HTTP Method to POST and build out the request body definition

image

The first flow action will be Flow Logic - Make a decision

Set the Decision Table to the decision defined earlier and set Execution to First decision that matches.

There's a other options here like branching which will expand out each answer, and 'Otherwise' which is like an else if.

Set the decision table input to the Trigger>Body>Number using the data pill picker.

image

Now we have a decision we can send the API call back out to the requesting system.

Find the REST Action you created and set the callback url, the output from the decision and the number from the trigger

image

That’s all the config on the ServiceNow end, now we can call our API.

We do this by sending a POST to the ServiceNow endpoint with the body like the following:

_{_

_“callbackURL”: string,_

_“number”: integer_

_}_

And you should get a POST in response within a couple of seconds and it will look something like this:

{Decision: "100 is Equal to or over 100!"}

You can use a tool like Postman or you can even do it within ServiceNow from the REST API Explorer.

And lastly, which isn't covered in this post, don’t forget to secure your API calls!

Links:

Decision Tables

Decision Builder

Tokyo Decision Builder release notes

REST API Trigger

View original source

https://www.servicenow.com/community/now-platform-articles/servicenow-decision-tables-as-a-queryable-business-rules/ta-p/2317363