Thursday, May 2, 2013

How to map existing SharePoint folder link to other MS CRM records:


Microsoft Dynamics CRM 2011 has the capability of uploading documents to SharePoint from within MS CRM record. In SharePoint a folder gets created when a document is clicked in CRM record and the URL is saved within CRM. But we can also use the same URL path to link more CRM records such that single SharePoint folder can be mapped with many records in CRM

In some scenario, the user would like to main documents from CRM Parent/Child records into a same folder in SharePoint. This can be programmatically achieved by linking the records to a single path to SharePoint.

Microsoft Dynamics CRM internally uses the URL of the parent object to determine the absolute URL for the child object. In this example we are not going to create any folder to child record when documents is clicked but going to link an existing path to Child records.

Once you have the Parent record created in CRM and corresponding record has a folder in SharePoint. Then the following SDK code is used to create a SharePoint document location record.

 SharePointDocumentLocation spLocation = new SharePointDocumentLocation();

        spLocation.Name = "location1";

        spLocation.Description = "SharePoint Document Location created for storing documents related to accounts";
        
         //Specify integrated SharePoint information below.

  String sharePointDocumentUrl = "http://<<sharepointserverUrl>>:<<portnumber>>/<<sitename>>/<<existing folder path>>";

        //Set the Absolute URL as above defined valid path

        spLocation.AbsoluteURL = sharePointDocumentUrl;

        //set the RegardingobjectId in which record would like to show the existing SharePoint folder 

        spLocation.RegardingObjectId = new EntityReference(<<Entitylogicalname>>, <<entityId>>);

        _service.Create(spLocation);


Hope this was helpful!!!!

No comments:

Post a Comment