Updating Sharepoint List from CRM Plugin

I got requirement to integrate CRM with sharepoint, where I need to update sharepoint list fields from crm opportunity fields. In order to send opportunity information to sharepoint I wrote a plugin and used sharepoint Lists.asmx and sitedata.asmx webservice to update sharepoint list. I use below code to update sharepoint list

//create list object
SharepointWS.Lists OpportunityList = new SharepointWS.Lists();
OpportunityList.Credentials = new System.Net.NetworkCredential(“User”, “Password”, “Domain”);

OpportunityList.Url = “http://tim/news/adsales/groups/domestic/_vti_bin/Lists.asmx”;

//Get list ID
XmlNode _List = OpportunityList.GetList(“List Name”);
string _ListID = _List.Attributes[“ID”].Value;

XmlDocument _Batchdoc = new XmlDocument();
XmlElement _BatchElement = _Batchdoc.CreateElement(“Batch”);
_BatchElement.SetAttribute(“OnError”, “Return”);
_BatchElement.SetAttribute(“ListVersion”, “1”);
string UpdateCmd = “” +
“” + _SharepointViewID + “”+
“” + _AccountName + “”+
“” + _OpportunityType + “” +
“” + _OpportunityStatus + “”;

XmlDocument _UpdateCmdDoc = new XmlDocument();
_BatchElement.InnerXml = _UpdateCmdDoc.OuterXml;
XmlNode _Result;
_Result = OpportunityList.UpdateListItems(_ListID, _BatchElement);



Filed under Share Point

2 responses to “Updating Sharepoint List from CRM Plugin

  1. Lee


    It’s not good to hardcode like this: OpportunityList.Credentials = new System.Net.NetworkCredential(“User”, “Password”, “Domain”);
    Do you have any solution to pass CRM credentials to SP?


    • mahenderpal

      you can store this information in MS CRM webconfig or you can pass this information from plugin registeration tool at the time of registeration (check for passing configuration data to ms crm plugin in sdk).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s