(this post was contributed by Brian Barnett, Senior Software Engineer on the MDS Team)
In my last post, I showed how to create a simple validation business rule. In this post, we are going to look at more advanced capabilities by using business rules to enable human workflow via email notifications. As with the last post, we will be using the sample Product model supplied with SQL Server 2008 R2 Master Data Services (MDS).
Because there is a lot I’ll be covering with this scenario, I’ll be breaking it into several parts. In this post I’ll lay out the scenario and walk through some of the initial model changes required.
Human Workflow Scenario
We will be creating a product notification workflow. To keep the scenario somewhat simple, we will look at a subset of the Product entity’s attributes but you can apply the same concepts to other attributes.
Here’s the scenario. Our business manager wants you to create a product workflow (see below).
We have two product lines we are concerned about – bikes and accessories. When a new bike is added, an email notification should be sent to the MDS Bike Inventory Dept so they can enter cost information. When a new accessory is added, an email notification should be sent to the MDS Accessories Inventory Dept to enter cost information. “Cost” in the diagram above and here refers to three cost attributes on the Product entity: StandardCost, DealerCosts, and MSRP. If any of the cost attributes are changed, then we need to change the product status to “Costs under review” and send an email to the management teams to review the changes, allowing them to approve or reject the changes. If bike costs need to be reviewed, then an email should be sent to the MDS Bikes Dept Management. If accessory costs need to be reviewed, an email should be sent to the MDS Accessories Dept Management. However, if the StandardCost for a bike is less than $500 or the StandardCost for an accessory is less than $10, then the change should be approved automatically. If any product is discontinued, then the status should be set to Discontinued.
Steps required
To accomplish these requirements, we need to do the following:
- Add a new ProductStatus entity.
- Add a new ProductStatus domain-based attribute to the Product entity.
- Add the ProductStatus domain-based attribute to the System attribute group.
- Add cost attributes to a change tracking group.
- Add list of members to the ProductStatus entity.
- Set up the proper security permissions for the groups.
- Configure MDS to send out email notifications.
- Create the business rules to enable the human workflow.
A lot of what we will do is one-time setup and can be used to facilitate other scenarios in other parts of MDS. I’ve described these steps in detail to help you understand some of the other MDS features. After the foundation is laid, building on it will be quicker.
Ok, let’s get started.
Step 1: Add a new ProductStatus entity
Follow these steps to add a new entity to contain the product status list of values.
- In Master Data Manager, click System Administration.
- On the Model Explorer page, from the menu bar, point to Manage and click Entities.
- Select the Product model from the Model dropdown list.
- Click the Add entity button.
- Enter ProductStatus in the Entity name field.
- Select No to Enable explicit hierarchies and collections.
- Click Save.
Step 2: Add a new ProductStatus domain-based attribute to the Product entity
Now we’ll add a ProductStatus domain-based attribute (DBA) to the Product entity to store the product’s status. You can do this one of two ways. The first is through Entity attribute maintenance and the second is from the System Admin Explorer page. I’m going to show you the second way.
If you just completed Step 1 above then you should be on the Entity Maintenance page. Follow these steps.
- On the Entity Maintenance page, on the menu bar, click Explorer.
- Click the + next to the Product model to expand it.
- Click the + next to the Product entity to expand it.
- Click the Product entity to display all the available Product model entities on the right-hand side of the screen.
- Next click the ProductStatus entity in the list on the right and drag it to the Product entity on the left (see screen shot below).
- You’ll see a “Processing. Please wait” message. After a few seconds you will see the ProductStatus domain-based attribute in the bottom of the list on the left.
Step 3: Add the ProductStatus domain-based attribute to the System attribute group
Attribute groups are a way to group related attributes together. They are displayed as separate tabs in member grids in Explorer. They are also a useful way to apply permissions to a group of attributes all at once.
Because attribute groups exist for the Product entity, you must also add the ProductStatus domain-based attribute to an attribute group for it to appear in Explorer. Let’s add it to the System attribute group.
If you’ve just completed Step 2 above then you should be on the Model Explorer page. Follow these steps.
- On the Model Explorer page, from the menu bar, point to Manage and click Attribute Groups.
- Select the Product model from the Model dropdown list.
- Select the Product entity from the Entity dropdown list.
- Under Leaf Groups, click the + to expand the System attribute group.
- Click the + next to Attributes to expand the list of System attributes.
- Click the Attributes node.
- Click the Edit button just above Leaf Groups.
- On the bottom of the screen you will see an Available and an Assigned list of attributes. The Assigned list contains the attributes assigned to the attribute group. Scroll to the bottom of the Available list to find the ProductStatus attribute.
- Select the ProductStatus attribute and click the Add button (right arrow).
- Click the Save button that is just above the Available list.
- The ProductStatus attribute should now appear under the System Attributes node (see below)
![clip_image007[6] clip_image007[6]](http://sqlblog.com/blogs/mds_team/clip_image0076_thumb_6E91359B.gif)
Step 4: Add the cost attributes to a change tracking group
We need to track the changes for the following cost attributes: StandardCost, DealerCost, and MSRP. We will need to modify two settings for each attribute to enable MDS to detect changes in the attribute values.
The settings are Enable change tracking and Change tracking group. Change tracking group allows you to create several change tracking groups with different attributes. For example, group 1 could contain StandardCost, DealerCostand MSRP; while group 2 could contain Color, Class, and Style.
Follow these steps to add an attribute to a change tracking group:
- In Master Data Manager, click System Administration.
- On the Model Explorer page, from the menu bar, point to Manage and click Entities.
- Select the Product model from the Model dropdown list.
- In the list of entities select the row for the Product entity.
- Click Edit selected entity.
- On the Edit Entity page, select the StandardCost attribute from the Leaf attributes list and click the Edit attribute button.
- Select the Enable change tracking check box and set the Change tracking group to 1.
![clip_image009[6] clip_image009[6]](http://sqlblog.com/blogs/mds_team/clip_image0096_thumb_70618B62.gif)
- Click Save attribute.
- Repeat this procedure for the DealerCost and the MSRP attributes. Use the same change tracking group number for each attribute in the group.
Step 5: Add list of members to the ProductStatus entity
Add the following members to the ProductStatus entity.
|
Name |
Code |
|
New |
New |
|
Review Cost |
ReviewCost |
|
Rejected |
Rejected |
|
Approved |
Approved |
|
Discontinued |
Discontinued |
- In Master Data Manager, select the Product model and a version then click Explorer.
- On the Model View page, from the menu bar, point to Entities and click ProductStatus.
- Click the Add button.
- Enter the Name and Code, as listed above, for each member. For the first four members click the Save and add another button after entering the Name and Code. On the fifth one click the Save and go back button to return to the member grid.
We now have the necessary model changes in place. Next time we will add the security groups we need and set their permissions.
*Update - This post references some features that are forthcoming in the future 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.