(this post was contributed by Brian Barnett, Senior Software Engineer on the MDS team)
This post is a first in a series that will explore what you can do with SQL Server 2008 R2 Master Data Services (MDS) business rules. It will introduce business rule creation and publishing. Here are some of the topics we will be covering in the future:
If there are other business rule topics you are interested in please drop us a line at email@example.com.
The ability to validate master data against a variety of rules and conditions is a key component to any best-practice master data management strategy. In MDS, business rules are used to enforce data integrity and help ensure completeness and accuracy of the master data.
Business rules are If/Then statements that can be created in the Master Data Manager user interface (UI) or the WCF API. If an attribute value meets a specified condition, then an action is taken. Possible actions include setting a default value, changing a value, performing attribute validation, or initiating a SharePoint workflow.
To use business rules, you must first create and publish your rules, then validate your data against the published rules. An administrator can validate an entire version of a model at one time. Other users can validate subsets of data against business rules.
If an attribute value doesn’t pass business rule validation, the value can still be saved. Validation issues are displayed in the UI, and a version cannot be committed until all attributes pass business rule validation.
In Master Data Manager, the Business Rule Designer is where you create and edit business rules. Drag and drop plays a key role in creation and editing of business rules, as shown below.
The screen has five main sections.
Contains the logical operator, condition, and action components.
Contains all the attributes for the specific entity/member type as well as any explicit hierarchy (consolidated) attributes.
Contains the conditions for which the action clause of the rule should be performed. You drag logical operators and conditions to this section. You can use the logical operators “AND” and “OR” to create combinations of conditions. All rules must have at least one logical operator. If no logical operator exists when you drag a condition component, an “AND” logical operator will automatically be added.
A condition is a Boolean (true or false) expression that is applied to an entity attribute. If the condition is true, the actions for the rule are performed.
A business rule does not require a condition. If no condition is specified, the actions for the rule are applied to all members.
Contains the actions that should be performed when the IF conditions are satisfied. You drag actions to this section.
An action is the consequence of a condition evaluation. If a specific condition is true, the action is initiated. You can also create a rule that initiates an action without a condition. In this case, the rule is applied to all members.
When you select a condition component in the IF section or an action component in the THEN section, the Edit section will display the individual condition or action component for editing. You drag attributes to this section as well as select and enter values.
The following steps will show you how to create a simple validation business rule using the sample Product model. Let’s say your business manager has indicated that any product manufactured in-house must have a fabrication time of between 1 and 10 days. So, in MDS we will create this rule:
InHouseManufacture is equal to Y
DaysToManufacture must be between 1 and 10
Now that the rule is published you are ready to try it out.
Because the updated value is outside the allowable DaysToManufacture range, a validation issue is created and displayed at the bottom of the screen showing the value violates the business rule we entered and published.
This was a simple example to get you started but you can see where we could add several more rules with more complex conditions to ensure DaysToManufacture is valid for a wide variety of product lines.
In the next Business Rules post, we will look at more advanced business rule capabilities by using business rules to enable human workflow via email notifications.