Skip to Content
Technical Articles
Author's profile photo Archana Shukla

Embed Business Rules SAPUI5 control in your custom applications

Pattern 1 – In App Extensions for Cloud Applications

This is the second blog of my blog series on Business Rules Consumption Patterns. In previous blog on Usage Scenario#1 of Pattern 1, I explained how business rules can be used directly from your custom applications which is deployed on SAP Cloud Platform.

Usage Scenario #1
Embed Business Rules SAPUI5 control in your custom applications

Business Rules can be also managed by the applications build by customers & partners. It gives the flexibility to provide an custom interface to the business users to directly manage rules without exposing the technical aspects like data-types, rulesets, rule service etc.

This is achieved by embedding Rule Builder SAPUI5 control in your custom application. Rule Builder is available from version 1.40 in SAPUI5 control library.

  • Follow ‘s excellent blog where he very nicely explains how to embed the rule-builder control in your application and then access it via Fiori Launchpad

Here are some important touch points in the SAPUI5 application (where you will embed the Rules Builder control) are:

  1. Coding your view.xml file to embed Rule Builder UI control of type Decision Table as shown:
<rules:RuleBuilder id="ruleBuilder" types="DecisionTable" editable="{path:'IsDraft', formatter: '.formatterIsDraft'}"/>

 

  1. Coding you Controller.js file to (a) initialize vocabulary, (b) configure and setup Rule Builder control, (c) implement actions for Activate, Edit, Deploy and Cancel buttons

You can know more in SAPUI5 samples to learn more on how to do that:
https://ui5.sap.com/#/entity/sap.rules.ui.RuleBuilder

 

  1. Deploying the application after you have embedded and coded the business rules control

 

  1. Accessing the application via the available application url. At a time, you can manage single rule via the rule builder control. The rules builder control needs information like rules project ID, rule ID, rules service ID and rule version, to be able to load the respective information.

 

Note: Currently only decision table based rules can be authored and managed using rule builder control. Soon, we will also release text-based rule builder control as well.

In this blog you learned about Consumption Pattern #2 where you saw how you can embed a decision table SAPUI5 control in your application. All you need to do is: (a) Insert the RuleBuilder control in your view.xml , (b) Implement the Controller.js to load the metadata of the rules via public APIs, (c) Code the button actions for Activate and Deploy (c) Finally, Deploy the application from SAP WebIDE and (d) Access the application to manage the business rules.

 

Sample Reference Application

I have shared a rulesmanager.zip project in GitHub which you can use to learn and reference on how-to embed the business rules in your application in your Neo environment.

(Instructions are simple and available inREADME file)

 

Related Blogs
SAP Cloud Platform Business Rules – Extensions and Consumption Patterns
Use SAP Cloud Platform Business Rules in your custom applications
Using Business Rules in SAP Cloud Platform Workflow
Embed Business Rules in Cloud Foundry Application

Assigned Tags

      22 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Pranjal Chugh
      Pranjal Chugh

      Hi Archana,

       

      Is there any other control available apart from Decision Table Editor?

       

      Regards,

      Pranjal

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Pranjal,

      We will soon release Text Rule as well but for now only Decision Table control.
      Is there anything else you looking for?

       

      Author's profile photo Former Member
      Former Member

      Hi Archana,

       

      Thanks for the blog . I imported the project and tried with the steps and not able to get the projectId from jQuery.sap.getUriParameters().get("ProjectId") , I passed the project ID from the rule url as mentioned in the doc. But getting null , did I missed any thing ? Please help

       

      Regards,

      Srikanth.

       

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Srikanth,
      As mentioned in the blog, you need to open the Business Rules editor and navigate to the project. On the URL you will find the project ID encapsulated under Project like

      https://bpmruleseditor-myrial.dispatcher.hanatrial.ondemand.com/index.html#//Projects(2e6417e0f0c94ef28d99fc6d9681bc3e,000001)/ProjectDetails/view

      • Are you trying the get the Project ID programatically? If yes, any reasons/use case for the same
      Author's profile photo Pranjal Chugh
      Pranjal Chugh

      Hi Archana,

       

      Can we use output of one rule as input to another rule ?

      Have you tried mapping a Decision tree to a decision table ? Or have you done any analysis on that?

       

      Regards,

      Pranjal

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Pranjal,

      Yes, you can use output of one rule to invoke another rule - but you need to do that either via cloud integration or in your custom application. In future, when we have Flow Rules, then you can define the order of the execution of rules.

      Can you elaborate more with example of what kind of mapping of Decision Tree to Decision Table you are referring to?

      Author's profile photo Sruti Gupta
      Sruti Gupta

      Hi Archana,

      I see that a new version of the code has been uploaded on GitHub. I am unable to understand what is the change in the code for Edit.
      I tried importing this piece of code in webIDE, and on running it I see that Rules are getting activated post deployment(can been seen in developer tools)

       

      Regards,
      Sruti

       

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Sruti,
      Yes there is a very small change in the Edit press function where refresh is moved after the edit has happened. This is because of some recent developments in the control due to which in-place editing was not appearing when using my code snippet.

      • As I do not activate explicitly, so in my code snippet whenever deploy function is called, I first activate and then deploy. But that is not mandatory for you. You can explicitly call Activate based on your requirement.

      Hope that helps,
      Archana

      Author's profile photo Sergio Poyer
      Sergio Poyer

      How to use the Value Help in RuleBuilder ui5 control?

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Sergio,
      There is no difference on using value help from the tool or from UI5 control. Please read my blog on Value Help

      Author's profile photo Sergio Poyer
      Sergio Poyer

      Hello Archana, thank you for reply.

      In Cloud Plataform Business Rules, I have the option for value help:

      But in RuleBuilder control, no have:

      Its any configuration? Can you help me?

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Sergio,
      Yes there is a configuration needed when you load the decision table control. Please download the rulesmanager.zip mentioned above. You will note these 2 changes in the code. You can directly copy and paste them from the zip file

      1. Expand call for Value help should include ValueSources

      urlParameters: {
      “$expand”: “DataObjects/Associations,DataObjects/Attributes,ValueSources
      }

       

      2. Modification in the Initialization of Vocabulary Model to include setting of model to expression language after each setData() call.

      oExpressionLanguage.setData(data);
      oExpressionLanguage.setModel(that.oVocabularyModel);

      Author's profile photo Ramon Lee
      Ramon Lee

      Hi Archana,

      The biggest functionality missing is to able to test for the end users.

      We were thinking of building the test functionality for our customer and is there a way we can retrieve the data objects metadata dynamically as there is some dataobject id available. If yes what is the url?

      Regards,

      RL

      Author's profile photo Karthikeyan Sathyanarayanamurthy
      Karthikeyan Sathyanarayanamurthy

      Hi Archana,

      I have worked extensively on SAP BRF+ and I was having a look at your posts. Very informative. Our entire Pricing logic runs on BRF+ where we take the output of one Rule and use it as an input to the other. I see you had mentioned about Flow rules in your previous posts. I did explore the Business rules in CF and found only Decision Table and Text rules. Do we know when Flow rules will be available ? And is there any roadmap to introduce more Expression Types like Table Operation, Loop, Formula, Procedural calls(In other terms – invoking On-prem GW services or something like this).

       

      My biggest question is can we deploy this to our On-prem CRM system to be used internally for something else or in One order transactions ?

       

      Regards,

      Karthik

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Karthik,

      Answers to your questions are as follows:

      • Do we know when Flow rules will be available ?
        • Flow rules are not available but for your use case decision orchestration will help. (read more here). Decision orchestration helps you to chain your rules and call output of rules inside another.
      • roadmap to introduce more Expression Types like Table Operation, Loop, Formula, Procedural calls?
        • Table operations like SELECT etc. is already available. Are you looking for this? If not can you explain with example.
        • Loop is in roadmap
        • Formula is already there, you can build vocabulary rules and use it as formula inside another rule expression.
      • can we deploy this to our On-prem CRM system?
        • If your CRM system is based on S/4HANA 1809 release and above then yes you can deploy it directly to your system.
      Author's profile photo Karthikeyan Sathyanarayanamurthy
      Karthikeyan Sathyanarayanamurthy

      Thanks Archana.. I will get going with the answers provided.. I will get back to you if I am stuck somewhere. Thanks for your answers..

      Author's profile photo Namrata S
      Namrata S

      Hi Archana ,

      I was trying to embed Business Rules in ui5 app . But the destinations for runtime and repository are not created automatically . Can you provide the destination config. Unable to load the app since metadata fails to load This is in Cloud Foundry

       

      Thanks

      Namrata

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Namrata,

      At the end of the blog, I have provided the sample for cf-rulesmanager, please refer that. You do not need any destination in CF and can work with the service key for business rules instance.

      Author's profile photo Namrata S
      Namrata S

      Hi Archana Thanks for your response

      As indicated in the below post I have followed all the steps . The service is deployed and tested on API hub . :

      https://blogs.sap.com/2019/04/13/embed-business-rules-in-cloud-foundry-application/

       

      How ever when i try to run the app :

      bpmrulesrepository/rules-service/rest/v1/projects I get a 404 for this url and projects are unable to load

      Can you please help with this

       

      Thanks

      Namrata

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Have you created a business rules instance, and referenced it with the UI project?

      Author's profile photo Namrata S
      Namrata S

      Yes Archana , It is referenced .

      Author's profile photo Prerna Kumari
      Prerna Kumari

      Hello Archana ,

      We are using SAP business Rule service as in SAP BTP to meet our client requirements. I would like to know if we have any satandard interface which allows only managing the decissions. After we ran the workflow booster we do see the below applications in Html5 applications.html5%20app

      but apart from rule editor applcation the other two application related to sapruledecisionviewer and saprulemanagedecision does not work.

      1. Could you please help me know if we have any standard interface to meet our requirement of managing the desision alone.
      2. We are trying to consume the standard Rest API to invoke the Business Rule from our custom application. In order to meet the above requirement in point 1 while trying to use the rule Builder ui5 control it asks us to use the Vocabulary odata service but we do not have any information about these odata services in the APi documentation.API%20hubCould you please let me know where could we find the vocabulary odata service as we have used the Business rule BTP service to create and deployed the project in cloud runtime.

      Thanks 

      Prerna