(this post was contributed by Brian Barnett, Senior Software Engineer on the MDS Team)
Up until this point we have been laying the foundation for enabling the human workflow. Along the way ( Part 1 , Part 2 , and Part 3 ) you’ve been exposed to other features within MDS. Now, we are going to be creating the business rules that drive the human workflow. See Part 1 to review the workflow.
*Note - This post references some features that are forthcoming in the RTM release of MDS and not available in the CTPs. It gives you an early look at what is coming to help plan for workflow scenarios such as this.
Step 8: Create the business rules to enable the human workflow
Here is what you will be learning:
- How to set business rule priorities.
- How to set email notifications to the different groups.
- How to use the “has changed” condition.
- How to use an entity’s domain-based attribute’s attributes in a rule condition or action component.
- How to set up compound conditions.
Here are the business rules we will need to add. Priority comes into play and is very important. It determines the order the rules are run. The rules will be processed in order beginning with the lowest value. The sample Product model comes with several business rules (check those out too) and the first sample rule has a priority of 10 so I decided to give the “New Product” rule below a priority of 5 so it runs first.
Notifications are sent when validation rules are broken. That is why we are setting the ProductStatus attribute to not valid below, to create a validation issue.
Priority |
Name |
Description |
Rule |
Notification (group) |
5 |
New Product |
After a product is entered default its status to New. |
IF None THEN ProductStatus defaults to New |
|
50 |
New Bike Product |
Notify the Bike Inventory Dept that a new bike has been entered so they can add the cost information. |
IF DBA.ProductSubCategory.ProductCategory is equal to 1 AND ProductStatus is equal to New THEN ProductStatus is not valid |
MDS Bikes Inventory Dept |
60 |
New Accessory Product |
Notify the Accessory Inventory Dept that a new accessory has been entered so they can add the cost information. |
IF DBA.ProductSubCategory.ProductCategory is equal to 4 AND ProductStatus is equal to New THEN ProductStatus is not valid |
MDS Accessories Inventory Dept |
70 |
Costs changes need review |
If any of the three costs attributes that we added to change tracking group 1 are changed then set the product’s status to ReviewCost. |
IF has changed in group 1 THEN ProductStatus equals ReviewCost |
|
80 |
Bike auto approve |
Auto approve cost under the specified amount. |
IF DBA.ProductSubCategory.ProductCategory is equal to 1 AND StandardCost is less than 500.00 THEN ProductStatus equals Approved |
|
90 |
Accessory auto approve |
Auto-approve cost under the specified amount. |
IF DBA.ProductSubCategory.ProductCategory is equal to 4 AND StandardCost is less than 10.00 THEN ProductStatus equals Approved |
|
100 |
Bike costs review |
Notify the Bike Inventory Dept managers that bike cost information has been changed and it needs to be reviewed. |
IF DBA.ProductSubCategory.ProductCategory is equal to 1 AND ProductStatus is equal to ReviewCost THEN ProductStatus is not valid |
MDS Bike Dept Mgmt |
110 |
Accessory cost review |
Notify the Accessory Inventory Dept managers that accessory cost information has been changed and it needs to be reviewed. |
IF DBA.ProductSubCategory.ProductCategory is equal to 4 AND ProductStatus is equal to ReviewCost THEN ProductStatus is not valid |
MDS Accessories Dept Mgmt |
120 |
Bike costs rejected |
Notify the Bike Inventory Dept that bike cost information has been rejected and it needs to be adjusted. |
IF DBA.ProductSubCategory.ProductCategory is equal to 1 AND ProductStatus is equal to Rejected THEN ProductStatus is not valid |
MDS Bikes Inventory Dept |
130 |
Accessory costs rejected |
Notify the Accessory Inventory Dept that accessory cost information has been rejected and it needs to be adjusted. |
IF DBA.ProductSubCategory.ProductCategory is equal to 4 AND ProductStatus is equal to Rejected THEN ProductStatus is not valid |
MDS Accessories Inventory Dept |
140 |
Discontinued status |
Set a product’s status to discontinued. |
IF DiscontinuedItemInd is equal to Y THEN ProductStatus equals Discontinued |
|
Let’s create two of the rules we need. I’ll leave the rest for you to enter as an exercise.
Let’s add the priority 50 rule from above. This rule will demonstrate how to use an entity’s domain-based attribute’s attributes in a rule condition or action component.
- In Master Data Manager, click System Administration .
- From the menu bar, point to Manage and click Business Rules .
- On the Business Rule Maintenance page, from the Model list, select the Product model.
- From the Entity list, select the Product entity.
- From the Member Type list, select the Leaf member type.
- From the Attribute list, leave the default of All .
- Click Add business rule .
- For the row that contains your new business rule, double-click a cell in the Name , Description , and Notification column to update the values as listed above.
- Click Edit selected business rule to open the Business Rule Designer .
- In the Components pane, expand the Conditions node.
- Click the “ is equal to ” condition and drag it to the IF pane's Conditions label.
- In the Entity-Specific Attributes pane, expand the “ ProductSubCategory ” attribute. Below it you will see all of the ProductSubCategory’s attributes. These are available for use in conditions and actions as well! For our rule we want to use the ProductCategory attribute. So drag ProductCategory to the Edit Condition pane's Select attribute label. You’ll notice that after you drop it the name will appear a little different - DBA.ProductSubCategory.ProductCategory. The “DBA” prefix indicates this is a domain-based attribute’s attribute. See screen shot at right.
- In the Edit Condition pane, select 1 in the Attribute value field. The value of 1 is the Code value for the Bike category.
- In the Edit Condition pane, click Save. The condition will be displayed.
- We need to add one more condition component – checking the product status. In the Components pane, click the “ is equal to ” condition and drag it to the IF pane’s And node.
- In the Entity-Specific Attributes pane, scroll down and click the “ ProductStatus ” attribute and drag it to the Edit Condition pane's Select attribute label.
- In the Edit Condition pane, select New in the Attribute value field.
- In the Edit Condition pane, click Save. The condition will be displayed.
- Now let’s add the action. In the Components pane, expand the Actions and then the Validation nodes.
- Click the “ is not valid ” action and drag it to the THEN pane's Actions label.
- In the Entity-Specific Attributes pane, scroll down and click the “ ProductStatus ” attribute and drag it to the Edit Action pane's Select attribute label.
- In the Edit Action pane, click Save. The action will be displayed.
- Click the green Back button (not the IE back button) to return to the Business Rule Maintenance page.
Let’s add the priority 70 rule from above. This rule will demonstrate how to use the “has changed” condition.
- Click Add business rule .
- Click Edit selected business rule to open the Business Rule Designer .
- In the Components pane, expand the Conditions node.
- Click the “ has changed ” condition and drag it to the IF pane's Conditions label.
- In the Entity-Specific Attributes pane, click the “ StandardCost ” attribute and drag it to the Edit Condition pane's Select attribute label. In this case you can actually drag any attribute over because the “ has changed ” condition doesn’t require an attribute; however, the Edit Condition pane does.
- In the Edit Condition pane, select 1 in the Change tracking group field.
- In the Edit Condition pane, click Save. The condition will be displayed (without the StandardCost attribute).
- Now let’s add the action. In the Components pane, expand the Actions and then the Change value nodes.
- Click the “ equals ” action and drag it to the THEN pane's Actions label.
- In the Entity-Specific Attributes pane, scroll down and click the “ ProductStatus ” attribute and drag it to the Edit Action pane's Select attribute label.
- In the Edit Action pane, select RvwCost in the Attribute value field.
- In the Edit Action pane, click Save. The condition will be displayed.
- Click the green Back button (not the IE back button) to return to the Business Rule Maintenance page.
Once all the business rules have been entered, on the Business Rule Maintenance page click the Publish button. On the confirmation dialog box, click OK . The rules’ statuses will change to Active .
Try it out
Since MDS uses Windows integrated security, to test with different users you’ll need to change the settings in IE to prompt you for the user name and password. Then log in as the various users to test out the different parts of the workflow.
In IE, select Tools | Internet Options .
- Select the Security tab.
- Select Local intranet
- Click Custom level…
- Scroll down to the Logon section and choose Prompt for user name and password .
- Press the OK button until the Internet Options dialog is closed.
Before we begin testing the workflow you may want to log in as each of your users. This will do a couple of things automatically:
- Add the user to the MDS user list
- Add the user to the MDS group’s membership list
If you are using local users you will need to update their email address in MDS. Follow these steps for each user.
- In Master Data Manager, click User and Group Permissions.
- On the Users page, click the context menu button (down arrow) next to the user and select Edit | General.
- Click the Edit button.
- Update the email address then click the Save button.
Now that the rules are published you are ready to try them out.
- Log into Master Data Manager as a user in the MDS Product Administrator group.
- In Master Data Manager, select the Product model and VERSION_1 version.
- Select Explorer .
- On the Explorer page click the Edit button.
- Click the Add member button to add a new member.
- Enter a Name and Code then click Save.
-
Enter a ProductSubCategory. Select either of the following because each of these are under the Bikes (Code = 1) ProductCategory, which we used in our rules:
- Mountain Bike
- Road Bike
- Touring Bike
- An email notification will be sent to the users of the MDS Bikes Inventory Dept group.
- Click on the link in the MDS Notification email
- Log into Master Data Manager as a user in the MDS Bike Inventory Dept group.
- On the member edit page, on the Inventory tab, enter values for the StandardCost, DealerCost, and MSRP attributes. You can test the workflow by entering StandardCost values less than 500 and values greater than 500. This user should only have update permission to the attributes on the Inventory tab. All attributes on the other tabs should be read only.
- If you enter a StandardCost value < 500 the product’s status should be set to Approve.
- If you enter a StandardCost value => 500 the product’s status should be set to Review Cost and users of the MDS Bike Dept Mgmt group will receive an email to review the costs.
- Click on the link in the MDS Notification email
- Log into Master Data Manager as a user in the MDS Bike Dept Mgmt group.
- On the member edit page, on the Inventory tab, review values for the StandardCost.
- On the System tab, change the ProductStatus attribute to either Rejected or Approved.
- Click Save.
This is an example of the notification email you should receive.
As you can see, enabling human workflow in MDS is a powerful and creative way of using business rules.