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.

Saturday, November 3, 2007

Client:Unexpected target(1)

I have never seen this error message from AX before this week when a client of us started getting it quite frequently.

At the client site they got this error in one of the sales form letter reports. But only when there was a note in the document management and only when they used printer, printer archive og e-mail as output.

We tried to change almost every propery on the report, in particlar those related with the output from DocuRef, but nothing helped.

Well after some hours of this we finally found the bug. Another team member had implemented a change from the standard to how the documents notes were printed. In the process he had moved the line to print these in the fetch method. But he moved it to a place before the place where the print job settings are loaded from the sales form letter setup.

So lessons learned: Don't try to print anything in a report if you intend to change the print job settings later.