Pages

Thursday, November 15, 2007

Control SharePoint with X++ code

I have never really seen an example where you control stuff like lists on a SharePoint site from X++ without involving EP.

I have managed to "Google" my way to a couple of samples where a custom dll acts as the middleman between AX and SharePoint. But since we now have the ClrInterOp stuff in AX 4.0, you should be able to work directly with SharePoint from X++ in my opinion. And true enough you can...

Togehter with a colleague here at thy:data we have made a few scenarios for working with a different lists in SharePoint from AX.

You could for example use such a solution in the cases where a full-blown EP would be out of proportions for the customers requirements.

Here is a little teaser, which you can run on the AX 4.0 SP1 VPC image if you have a copy of that:
static void HelloSharePoint(Args _args)
{ 
Microsoft.SharePoint.SPSite spSite; 
Microsoft.SharePoint.SPWeb  spWeb; 
; 
spSite = new Microsoft.SharePoint.SPSite('http://ax401vpc');

spWeb = spSite.OpenWeb();

info (strFmt("Site name: %1", ClrInterOp::getAnyTypeForObject(spWeb.get_Title())));

spSite.Close();  
spWeb.Dispose();
}

In AX you need to add a reference to the Microsoft.SharePoint dll.