SharePoint Workflow Integration with Master Data Services
SQL Server Technical Article
Writers: Tyler Graham, Suzanne Selhorn
Technical Reviewer: Minh Pham
Published: March 2010
Applies to: SQL Server 2008 R2 Master Data Services
Summary: This paper details the steps necessary to configure Microsoft® SQL Server® 2008 R2 Master Data Services to initiate a Microsoft® SharePoint® workflow.
With Master Data Services, you can use business rules to create basic workflow solutions. You can automatically update and validate data and have e-mail notifications sent based on conditions you specify. Business rules in Master Data Services are intended to manage the most common workflow scenarios.
If your workflow needs require more complex event processing, such as multi-tiered approvals or complex decision trees, you can configure Master Data Services to send data to SharePoint and start a SharePoint workflow.
Each time you apply the start Workflow business rule to your entity, records that meet the business rule conditions are passed to the Service Broker queue. At regular intervals, the MDS Workflow Integration service calls a stored procedure in the Master Data Services database. This stored procedure pulls the records from the Service Broker queue and passes them to the SharePoint workflow.
Before configuring Master Data Services to work with a SharePoint workflow, you must have the following software available:
- SQL Server 2008 R2 Master Data Services November CTP or later
- Microsoft® Visual Studio® 2010 Beta 2 Ultimate or later
- Microsoft SharePoint Foundation 2010 or Microsoft SharePoint Server 2010
This software will be installed in the following procedures.
To send master data from Master Data Services to a SharePoint workflow, you will complete the following steps.
- Step 1: Install Master Data Services
- Step 2: Install SharePoint
- Step 3: Update the Web Configuration File
- Step 4: Install and Start the Workflow Integration Service
- Step 5: Install Visual Studio
- Step 6: Create a Workflow in Visual Studio
- Step 7: Create and Apply Business Rules in Master Data Manager
Step 1: Install Master Data Services
First, install Master Data Services. For more information, see the SQL Server 2008 Books Online topic “How to: Install Master Data Services” (http://msdn.microsoft.com/en-us/library/ee633762(SQL.105).aspx)http://msdn.microsoft.com/en-us/library/ee633762(SQL.105).aspx).
This white paper uses C:\Program Files as the folder where Master Data Services is installed.
Step 2: Install SharePoint
Master Data Services requires a version of SharePoint to be on the server where Master Data Services is installed. This version of SharePoint can host the workflow, but it does not need to.
The minimum version of SharePoint required is SharePoint Foundation 2010. You can install SharePoint Foundation from:
Note: The required collation for SharePoint Foundation database installations is Latin1_General_C1_AS_KS_WS. Other collations are not supported. For more information about setting up the SharePoint Server, see the SharePoint topic “Setting Up the Development Environment for SharePoint Server” (http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx).
Step 3: Update the Web Configuration File
You can now edit the Master Data Services Web configuration file to include the name of your Master Data Services server and database, and a SQL Server user that the service will use to access the stored procedure in the Master Data Services database.
Create a User with Access to the Stored Procedure
- Open SQL Server Management Studio and connect to the SQL Server Database Engine instance that hosts the Master Data Services database.
- Create a login named workflowusr. The password can be a secure password of your choice.
- For the Master Data Services database, create a user named mds_workflow_user and map it to the workflowusr login.
- After entering the name and login, click the Securables page and search for the stored procedures object type. Find [mdm].[udpExternalActionsGet] and grant EXECUTE permission to it.
Edit the Master Data Services Web Configuration File
- On the server where Master Data Services is installed, open Microsoft.MasterDataServices.Workflow.exe.config from C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication\bin.
- Find this setting: <setting name="ConnectionString" serializeAs="String">
- Update the value to reflect the server, database, and user. If your SQL Server installation uses case-sensitive collation, then the name of the database must be entered in the same case as in the database. For example, <value>Server=myServer;Database=myDatabase;Integrated Security=False;User Id=workflowusr; Password=myPassword</value>
- Save and close the file.
Step 4: Install and Start the Workflow Integration Service
Next, install and start the SQL Server MDS Workflow Integration service.
Copy the Install File
- On the server where Master Data Services is installed, open an elevated command prompt.
- Go to %Windows%\Microsoft.NET.
- If you have more than one Framework folder, determine which is the most recent and go to that folder.
- Go to the Framework folder’s subfolder, for example Framework\v4.0.21006.
- Confirm that InstallUtil.exe is in the folder.
- Copy InstallUtil.exe to the Master Data Services bin folder. At the command prompt, type: copy InstallUtil.exe C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication\bin
- Press ENTER to copy the file. Do not close the command window.
Install the Service
- At the command prompt, go to C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication\bin.
- Type: InstallUtil Microsoft.MasterDataServices.Workflow.exe
- Press ENTER. A dialog is displayed, prompting for a user name and password.
- Type a Windows domain user name and password. It is recommended that the user be the W3WP Identity on the SharePoint Application Pool. Alternately, the user must have Read-Write access to the SharePoint Content Database.
- Click OK.
Start the Service
- From the Start menu, click Run.
- Type: Services.msc
- Click OK. The Services snap-in opens.
- Find the service called SQL Server MDS Workflow Integration.
- Double-click the service.
- Click Start.
- Click OK.
Step 5: Install Visual Studio
Install Visual Studio 2010 Beta 2 or later. You will use Visual Studio to create your workflow.
You can install Visual Studio from:
Step 6: Create a Workflow in Visual Studio
Create the SharePoint Workflow
Now you can create the SharePoint workflow for your organization.
- Open Visual Studio 2010.
- Using the SharePoint 2010 templates, create a ‘Sequential workflow’ project.
- Drag the OnWorkflowActivated control from toolbox to the designer for your solution.
- Right-click the control and choose Generate Handlers.
- The data passed from the workflow service is contained in this string: string MDSData = workflowProperties.InitiationData;
- Compile and deploy your workflow.
Add a DLL Reference to Workflowactions.dll
For your workflow to work, you must add a DLL reference to a file on the SharePoint server that will host the workflow.
Note: The SharePoint server that will host the workflow can be the server where you installed SharePoint in step 2, or it can be another SharePoint installation.
- In Visual Studio, in Solution Explorer, right click References.
- From the menu that is displayed, click Add Reference.
- On the SharePoint server that will host the workflow, browse to %Program files%\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Workflow.Actions.dll.
- Click OK.
Step 7: Create and Apply Business Rules in Master Data Manager
Next, create a business rule in Master Data Manager. When data is validated against the business rule, the Service Broker queue is populated. The service checks the queue, sends the data to SharePoint, and then clears the queue.
Create and Publish a Business Rule
You must first create and publish the business rule that will start the workflow when applied.
You should ensure that your business rule contains actions that change attribute values, so that the rule evaluates to false after it has been applied once. For example, your business rule might evaluate to true when a Price attribute value is greater than 500 and the Approved attribute value is blank. The rule can then include two actions: one to set the Approved attribute value to Pending and one to start the workflow.
Alternatively, you may want to create a rule that uses the “has changed” condition and add your attributes to change tracking groups. Note: This functionality is not available in SQL Server 2008 R2 November Community Technology Preview and earlier.
To create a business rule in Master Data Manager, you must have permission to the System Administration functional area and be a model administrator for the model you want to create the business rule for.
- In Master Data Manager, click System Administration.
- From the menu bar, point to Manage and click Business Rules.
- On the Business Rule Maintenance page, select a model, entity, member type, and attribute.
- Click Add business rule. A row is added to the table and is highlighted.
- Click Edit selected business rule.
- In the Components pane, expand the Conditions node.
- Drag conditions to the IF pane’s Conditions node.
- In the Entity-Specific Attributes pane, click an attribute and drag it to the Edit Action pane’s Select attribute label.
- In the Edit Condition pane, complete any fields and click Save item.
- In the Components pane, expand the Actions node.
- Under External action, drag Start Workflow to the THEN pane’s Action label.
- In the Entity-Specific Attributes pane, click any attribute and drag it to the Edit Action pane’s Select attribute label. This attribute has no bearing on the workflow process.
- In the Edit Action pane, in the Workflow type box, type SPWF.
- Optionally, select the Include member data check box. Choose this to include attribute names and values in the information passed to SharePoint.
- In the Workflow site box, type the name of your SharePoint site. For example, http://site_name.
- In the Workflow name box, type the name of your workflow from Visual Studio. In Visual Studio Solution Explorer, this value is in the Display Name field.
- At the bottom of the page, click Save.
- At the top of the page, click Back. The Business Rule Maintenance page opens.
- Click Publish business rules.
- On the confirmation dialog box, click OK. The rule's status changes to Active.
Apply Business Rules
Now you must apply the business rule to your data. This action passes the data to the Service Broker queue.
- From the Master Data Manager home page, click Explorer.
- Select the entity with members you want to validate.
- Click Apply business rules.
The SQL Server Service Broker queue is populated. When the service checks the queue, it sends the data to SharePoint and clears the queue.
When configuring Master Data Services to work with a SharePoint workflow, you might encounter any of the following issues.
SharePoint Doesn’t Receive Data
If SharePoint doesn’t receive the data, you can try debugging the workflow service or viewing the Service Broker queue to determine if the correct data is still in the queue.
Debug the Workflow Service
- Stop the service if it is running.
- Open a command prompt.
- Go to the location of your service and type: Microsoft.MasterDataServices.Workflow.exe –console
- Press ENTER.
- In Master Data Manager, update your attribute and apply business rules again. Detailed logs are displayed in the console window.
View the Service Broker Queue
The Service Broker queue that contains the master data passed as part of the workflow is: mdm.microsoft/mdm/queue/externalaction
If the service cleared the queue properly, this queue should be empty.
If there is data in the queue that you want to remove, you can run the following SQL script to clear the queue. You must change myDatabase to the name of your Master Data Services database.
declare @conversation uniqueidentifier
while exists (select 1 from [myDatabase].[mdm].[microsoft/mdm/queue/externalaction])
set @conversation = (select top 1 conversation_handle from [myDatabase].[mdm].[microsoft/mdm/queue/externalaction] )
end conversation @conversation with cleanup
SharePoint Workflow Isn’t Starting
For more information on debugging a SharePoint workflow, see “Walkthrough: Creating and Debugging a SharePoint Workflow Solution” (http://msdn.microsoft.com/en-us/library/bb386168.aspx).
For more information:
http://www.microsoft.com/sqlserver/ : SQL Server Web site
http://technet.microsoft.com/en-us/sqlserver/ : SQL Server TechCenter
http://msdn.microsoft.com/en-us/sqlserver/ : SQL Server DevCenter
Did this paper help you? Please give us your feedback. Tell us on a scale of 1 (poor) to 5 (excellent), how would you rate this paper and why have you given it this rating? For example:
- Are you rating it high due to having good examples, excellent screen shots, clear writing, or another reason?
- Are you rating it low due to poor examples, fuzzy screen shots, or unclear writing?
This feedback will help us improve the quality of white papers we release. Send feedback.