Skip to Content

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.

(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

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

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

     

    (0) 
  2. 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

    (0) 
    1. Archana Shukla
      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?

      (0) 
  3. 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

     

    (0) 
    1. Archana Shukla
      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

      (0) 

Leave a Reply