Introduction
In this series of post, I’ll show how you can integrate Microsoft Office SharePoint Server 2007 with another line of business system, more specifically Dynamics AX.
The purpose is to create a custom field type, which can be added as a column to a SharePoint list. This SharePoint column renders a dropdown box with values from a Microsoft SQL Server table’s column. As such, in stead of duplicating the possible values on your SharePoint box each time new values are added in your line of business system, the available values for this SharePoint column are always in synch with your line of business system.
This first post describes how to create your connection between Microsoft Office SharePoint Server 2007 and Dynamics AX.
The second post describes how to create the custom field type.
Currently however, the DAX project activities we are receiving in our dropdown list are based on a specific project.
In this post, I’ll describe how to receive those project activities for a project depending on the site the issue list is part of.
Preparation
Suppose you have created a Subsite for all your projects (called Projects) under the top level Web Site. For each project, you’ve created a specific Subsite under the Projects Subsite.
What we’ll need first, is that we can link this Subsite to a Dynamics AX ProjId. To achieve this, set the URL name of eacht Project Subsite to <ProjId>_<dataAreaId>. So the url should look like http://<webapplication>/projects/<ProjId>_<dataAreaId>.
Adapt the Field Rendering Control
In the Field Rendering Control DAXProjActivityTxtFieldControl.cs we’ve created a method PopulateDAXProjActivityTxts. In this method, we used two arguments, being the ProjId and the dataAreaId, which we gave a hardcoded value. We are going to make this values depending on our url.
- First of all we need to add an additional using statement to be able to use the SPWeb Class.:
using Microsoft.SharePoint;
- In the method PopulateDAXProjActivityTxts, look for the lines where we set a value for the arguments passed to our SQL query (args[0] = …). Replace those lines with the following code:
//return the Web site of the current request
SPWeb web = SPContext.Current.Web;
// url of the Web site
string path = web.Url;
Uri uri = new Uri(path);
// get part of url where ProjId and dataAreaId are stored
string proj = uri.Segments.GetValue(2).ToString();
char[] splitter = { '_' };
string[] splittedproj = proj.Split(splitter);
// ProjId
args[0] = splittedproj[0];
// dataAreaId
args[1] = splittedproj[1];
- Build your Visual Studio project: the post-build events added previously will install everything needed to your SharePoint environment.
Result
When you create or edit an item in the list, your drop down column will be loaded with values from your Microsoft Dynamics AX source: but now those values will be variable: they’ll depend upon the part of your url where you created the link with your ProjId and dataAreaId.
Post a Comment