Kony Fabric console User Guide: Integration > Advanced Configurations > Why Use Rules

Rules

Kony Fabric provides the ability to write custom code as pre and post processors to modify request and response parameters to service calls. Historically custom code can be implemented either in Java or JavaScript. To simplify implementing custom logic in pre and post processors, a new Rules option is introduced from Kony Fabric V8 SP4. You can use the Rules option to define your custom logic as a set of rules. This option makes defining pre and post processor custom logic closer to human language and is built using MVEL.

Note: The Rules functionality is supported only for the pre and post processor of integration services.

Built-in Objects

The following objects help you to write rules in Kony Fabric.

Objects Description
"configurationParameters"

Used to access the Server and Client App parameters that are set by the developer in the App Services console. This is equivalent to using ConfigurableParameters in Java.

"continueExecution"

Used in the Pre-processor to terminate back-end calls.

Set the value to false if you want to terminate the back-end call. By default, the value is set to true.

"customMetrics"

This is used to access custom metrics.

For more details to create custom reports and Metrics, refer Custom Reporting – Metrics, Reports, and Dashboard Guide

“deviceHeadersMap”

Used to set headers that are passed to the client and is equivalent to using setDeviceHeaders in Java.

"headerMap"

Used to access the header map of a request. A client can directly access the header map or the individual key-value pairs of the header map.

“identityHandler"

Used to access the identity attributes when a service is protected by an identity service.

"inputMap"

Used to access the input map of a request. A client can directly access the input map or the individual key-value pairs of the input map.

"logger" Used to add a log statement with the appropriate level.
"response"

Used to modify the response body and is equivalent to using setResponse in Java.

"results"

Used to modify the results. A Result is an abstraction of a back-end response. The Result is a collection of Params, Data-sets, and Records. For more details, refer Result.

"resultCache"

Used to access the cache in pre-processor and post-processor. This is equivalent to using ResultCache in Java.

"servicesManager"

Used to invoke an integration service with the specified service id, operation id and version.

"session"

Used to modify the session that is associated with the request.

For more details, refer Session

A client can access values from the session and the individual attributes of the session.

“statusCode” Used to set the status code of the response and is equivalent to using setStatusCode in Java.
"ua"

Used to access the User Agent Header of the request.

Sample Rules

 

Copyright © 2019 Kony, Inc. All rights reserved.