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);

2 thoughts on “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?


    1. mahenderpal Post author

      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

Your email address will not be published. Required fields are marked *