thinking in rules

Managing Complex Business Rules with Salesforce.com

ROAD Team | 10/28/2014

With the growing popularity of Salesforce.com and the Force.com platform, some InRule clients have inquired about the possibility of integrating InRule with Salesforce.

The Force.com platform allows configuration of business data objects without changing code.  An administrator, developer, or business user can work with a web interface to create business objects that are not included out of the box with a default Salesforce environment. The flexible metadata feature allows the Force.com platform to be used to build applications that can potentially address just about any given business problem.

In addition to configuring business objects, Force.com also offers a set of enterprise features that can easily be incorporated into any application that is built on the platform. These built-in features allow applications to be built much more quickly and with less cost and risk than building applications completely from scratch. Some of these include:

  • Data model – an optimized, relational database that has corresponding in-memory objects.
  • UI – A series of user interface forms that manipulate business objects. These forms can be reconfigured without changing code.
  • Role Based Security – User security that is manageable on an object-by-object basis.
  • Queries and Views – Sets of objects can be related and aggregated with reusable “views”.
  • Search – Each object set can be searched by a configurable combination of fields and complex clauses.
  • Centralized Services for Line-of-Business Data – SOAP and REST web service APIs are available for integration with other back-end systems, web portals, and mobile applications.

Although Salesforce has strong support for managing data and user interfaces, many real-world business problems require that complex business logic be applied to application data to make decisions. Some examples include insurance rating and claims, loan origination, call center cross-selling, financial services monitoring, and government compliance for health care benefits or taxes.

Often these real-world problems must derive decisions based on hundreds of data points or distinct rules. Often rules must be chained together conditionally as logic is iteratively applied to a set of data. When an application requires complex business logic in Salesforce, this generally requires that a developer writes custom code using the Apex language built into the Force.com platform.

By integrating InRule with Salesforce.com and the Force.com platform, solutions can be created that allow complex business logic to be created and maintained by business users instead of developers. InRule can play a key role in the Salesforce offering by extending the powerful “no code” features of Salesforce to support complex business logic with configuration instead of with hard coded classes and methods.

In addition to the ability to author and execute business rules, the InRule BRMS helps to extend Salesforce to address some of these common requirements:

Efficiently execute complex logic that drives real business decisions – Complex decisions often require consideration of hundreds of data points and rules. Data points may be aggregated across complex entity hierarchies comprised of many different data types and collections.

Have business visibility into the logic that drives complex decisions – Business logic should be easily readable and reportable for business users, not just software developers. This business should be comfortable with their understanding of how an application works.

Have the ability to easily version and change rules over time – Rules often change over time. An application may need to be quickly updated to accommodate changes, but include the ability to execute older versions of rules when necessary.

Change the behavior of Salesforce without having to change code – Business users and subject matter experts should be empowered to make changes to the rules, just as easily as they can control other declarative features of Salesforce such as the data model or user interface. Complex business logic should not be hard‐coded and maintained only by software developers.

Deploy as a completely cloud-based solution – No “on premise” hardware should be required, including management and execution of business rules.

InRule and Salesforce – Integration Scenario Details:

The key to empowering Salesforce with complex business logic is giving users access to the powerful object model that serves as the core of the Force.com application platform. Once the user has the ability to map Salesforce objects to InRule entities, the user can then author and test rules directly against Salesforce data using irAuthor and irVerify.

Much like Force.com, the InRule rule engine offers strong support for hierarchical and relational data. Within a given rule application, data can be considered across parent-child relationships within a single rule request. These relationships can take the form of collections (1 - * relationships) or 1 – 1 relationships.

In addition to the abilities of both products to handle relational data, both products also offer the ability to declaratively configure “objects” and “fields”. Both products also allow for different strongly-typed business objects and fields to be accessed with loosely-typed API interfaces. Because of these inherent similarities and flexible interfaces, it is possible to build a reusable mapping component that can convert any given graph of loosely-typed Salesforce objects to InRule entities, and vice versa.

To assist with the mapping process, InRule can provide a custom component called the “sObjectMapper”. Given any root InRule entity and Salesforce object, the sObjectMapper can map hierarchical data between Salesforce and InRule.

 

 

 

 

 

 

 

 

 

 

 

 

Using Force.com metadata to drive mapping, rule authoring, and testing:

The sObject mapper requires metadata from both InRule and Salesforce to complete the mapping process. The rule author can enter information about Salesforce objects and fields in irAuthor. This metadata is then consumed by the sObjectMapper when reading data:

Once the metadata mapping is completed, the user can import the custom Salesforce connector component, and test with Salesforce data directly in irVerify. The screen shot below shows a simple collection filtering rule that is used to validate a stock trade. Using the custom Salesforce connector component, the rule author can test trade data against a list of stocks using irVerify.

Customizing SOQL Queries with business rules:

The custom Salesforce connector component can accept text filters that can be used as “where” clauses that are then translated into SOQL and executed against Salesforce. The connector component allows the rule author to work in InRule Business Language when constructing the queries, but then translate to SOQL at runtime. A simple example is provided below, where Stocks are filtered by their Active Date versus the Transaction Date of an Order:

A brief overview of the translation and query operation is noted below:

Summary:

Using metadata mapping techniques and the Salesforce.com API, InRule can be easily integrated with the Force.com platform to allow for the inclusion of complex business logic in solutions that are developed on the Salesforce.com. Look for more information about formal product offerings from InRule in this area over the coming months.

In the meantime, if you are interested in sample code used in the custom connector component noted in this article, then please contact the InRule ROAD Services Team for more information.

As a final thought, below is a diagram depicting one possible architecture that can be used to integrate complex business logic from InRule with Salesforce.com.
Editor's Note: To learn more, please download our whitepaper, Case Management Patterns and Practice Using InRule and Salesforce.com.


comments powered by Disqus