Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 


This blog post will cover the steps to invoke a Business Rule from a custom UI5 application using Business Application Studio in Cloud Foundry environment of SAP Business Technology Platform.

Disclaimer: I do not intend to explain about Business Rules concepts in this blog or how to create and deploy them in BTP CF. There are quite a few blogs beautifully explaining them. You can follow the blog from muralidaran.shanmugham2 to configure Business Rules in CF. I have used the same as a sample to invoke them from ui5 app.



  • Please make sure your BTP account is set up with Boosters for Workflow Management. Destination BUSINESS_RULES is automatically configured as a result of the Booster set up. We will be using this in our SAP UI5 app.

  • BAS set up is done and respective roles are assigned

  • Business Rules created and deployed in CF


Steps to Invoke Business Rules

Step 1: Create a mta project and add Fiori module to it

  • Create a mta project using the command yo basic-multitarget-application

  • Now, lets add a fiori app to this mta project. Go into the project we just created and add a fiori module using the command yo fiori-module and fill in all the information required :

Create Fiori Module


Step 2 : Update mta.yaml file with Business Rules Service Instance

Go to mta.yaml file and include the business rules service instance which was automatically created with the help of Booster set up of Workflow Management. (wm_businessrules is the name of my instance)

Business rules instance in mta

Step 3 : Update xs-app.json of Fiori Module

Next, update the route in your Fiori Module application. For that, open xs-app.json file of your fiori module and add this route. Make sure you add this route before the generic routes.

  • Also ensure that the “authenticationMethod” is “route” (check line 3 in screenshot)

"source": "^/BUSINESS_RULES/(.*)$",
"target": "$1",
"destination": "BUSINESS_RULES",
"authenticationType": "xsuaa"



Step 4 : Update Controller.js of Fiori Module to call Business Rules APIs

Update Controller.js file to call business rules-service API. Before calling the API to invoke the business rule, you need to first get the xsrf-token and then call the API.

  • To do so, you will also need information of the application ID that will be prefixed with API host URL. You can get this information from the manifest.json file inside your fiori module as –> id. Application ID is the ID without dot.

For Example: In below example the –> id is ns.fioriBRmodule so the                                                            application ID becomes nsfioriBRmodule


  • Now you need to update the code in Controller.js to first make a GET API call for XSRF  token

    For eg :

  • Next, you will use this xsrf-token to make the POST API call to invoke the Business Rule. You will need to pass the body which contains the rule service id and the data needed for the business rules to be executed (know more about the APIs from here). I have used V2 apis here as version1 apis are deprecated.

For eg :

 var jsonData = {
"RuleServiceId": "XXXXXX",
"Vocabulary": [
"Customer": {
"CreditRating": "AAA",
"AvgOrderValue": 3000
//Then invoke the business rules service via public API
url: " /nsfioriBRmodule/BUSINESS_RULES/rest/v2/workingset-rule-services",
method: "POST",
// contentType: "application/json",
data: JSON.stringify(jsonData),
async: false,
headers: {
"X-CSRF-Token": token,
"Content-Type": "application/json"
success: function (result1, xhr1, data1) {
if (result1 != null) {
alert("post success");
//info: the output from rules will be wrapped in result1 object, you can
// access this json object to get the output variable.


Step 5 : Build and Deploy the application

  • Right click on the mta.yaml file to Build the mta project

  • Once successful, right click on the generated .mtar file and Deploy to CF

Step 6 : Test the application

Finally, test the application from the SAP BTP cockpit. Pls append the application ID to the app link.

For eg  :

1 Comment
Labels in this area