Delete document from SharePoint 2010 via SOAP Web Services – UpdateListItems

Delete a document from SharePoint 2010. You NEED both the ID and the FileRef.

// Delete the sharepoint document
System.Text.StringBuilder oSb = new System.Text.StringBuilder();
oSb.Append("     <Batch OnError=\"Continue\"> ");
oSb.Append("         <Method ID=\"1\" Cmd=\"Delete\"> ");
oSb.Append("             <Field Name=\"ID\">" + fileID + "</Field> ");
oSb.Append("             <Field Name=\"FileRef\">" + URLofFile + "</Field> ");
oSb.Append("        </Method>");
oSb.Append("    </Batch>");
 
string sResult = oSb.ToString();
XmlDocument CAMLqueryXML = new XmlDocument();
CAMLqueryXML.LoadXml(sResult);
 
// Execute GetListItems
XmlNode queryResults = lists.UpdateListItems(SPLibraryName, CAMLqueryXML);

Retrieve document ID from SharePoint 2010 via SOAP Web Services – GetListItems

Get a specific item from a SharePoint 2010 library using GetListItems.

// Build the CAML Query
System.Text.StringBuilder oSb = new System.Text.StringBuilder();
oSb.Append("     <Query>");
oSb.Append("         <Where>");
oSb.Append("             <Eq>");
oSb.Append("                  <FieldRef Name=\"FileLeafRef\" />");
oSb.Append("                  <Value Type=\"Text\">" + fileName +"</Value>");
oSb.Append("             </Eq>");
oSb.Append("        </Where>");
oSb.Append("    </Query>");
 
string sResult = oSb.ToString();
XmlDocument CAMLqueryXML = new XmlDocument();
CAMLqueryXML.LoadXml(sResult);
 
//Build the CAML Query Options
oSb.Clear(); // Clear the string builder
oSb.Append("    <QueryOptions>");
oSb.Append("         <Folder>" + libraryName + "/</Folder> />");
oSb.Append("    </QueryOptions>");
string CAMLqueryOptions = oSb.ToString();
 
XmlDocument CAMLqueryOptionsXML = new XmlDocument();
CAMLqueryOptionsXML.LoadXml(CAMLqueryOptions);
 
// Execute GetListItems
XmlNode queryResults = lists.GetListItems(libraryName, null, CAMLqueryXML, null, null, CAMLqueryOptionsXML, null);

Update Custom Columns from SharePoint 2010 via SOAP Web Services – UpdateListItems

Here’s a query to update a file’s custom columns in SharePoint 2010.

// Build the CAML Query
System.Text.StringBuilder oSb = new System.Text.StringBuilder();
oSb.Append("     <Batch OnError=\"Continue\" >");
oSb.Append("         <Method ID=\"1\" Cmd=\"Update\">");
oSb.Append("             <Field Name=\"ID\">" + fileID + "</Field> ");
oSb.Append("             <Field Name=\"Custom_x0020_Column\">" + customColumnText + "</Field> ");
oSb.Append("             <Field Name=\"Test_x0020_123\">" + test123Text+ "</Field> ");
oSb.Append("        </Method>");
oSb.Append("    </Batch>");
 
string sResult = oSb.ToString();
XmlDocument CAMLqueryXML = new XmlDocument();
CAMLqueryXML.LoadXml(sResult);
 
// Execute UpdateListItems
System.Xml.XmlNode result = lists.UpdateListItems(libraryName, CAMLqueryXML);

Check in a file into SharePoint 2010 via SOAP Web Services – CheckInFile

Checking in a a file into Sharepoint using Lists.asmx.

// Check the file in to sharepoint
lists.CheckInFile(destinationUrl, "Text for the checkin", "1");

A string representation of the values 0, 1 or 2, where 0 = MinorCheckIn, 1 = MajorCheckIn, and 2 = OverwriteCheckIn.

Microsoft.Crm.CrmConfigObjectNotFoundException: User Was Not Found

Whenever I ran a report in SSRS I kept getting:

“Microsoft.Crm.CrmConfigObjectNotFoundException: User Was Not Found”

It’s weird because I was able to login to CRM with that user account. It turns out that the user had been deleted from AD then re-added (without my knowledge). I disabled the current user in CRM and re-added the user to CRM and everything worked just fine from there on out. It’s almost like the old user’s GUID wasn’t matching with the new user’s GUID.

Thanks,
Ry

Return top