Skip to Content
Technical Articles

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

21 Comments
You must be Logged on to comment or reply to a post.
  • 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.

     

  • 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

    • 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?

  • 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

     

    • 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

      • 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?

        • 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);

  • 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

  • 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

    • 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.
  • 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