Reputation: 360
I am batch updating sharepoint list items using the code below and am trying to figure out if I can also update the content type of the item using batch update. This is for Sharepoint 2010 and I can only use webservices. I have not been able to find an example anywhere.
public static void UpdateListItems(string SiteURL, string ListName, int[] ItemIDs, List<string> FieldNames, List<object> Values)
{
using (ListsSoapClient ls = GetListSoapClient(SiteURL))
{
XDocument xDoc = new XDocument(new XElement("Batch"));
xDoc.Root.Add(new XAttribute("OnError", "Continue"));
xDoc.Root.Add(new XAttribute("PreCalc", "TRUE"));
int ID = 0;
for (int i = 0; i < ItemIDs.Count(); i++)
{
ID++;
XElement xMethod = new XElement("Method",
new XAttribute("ID", ID),
new XAttribute("Cmd", "Update"),
new XElement("Field",
new XAttribute("Name", "ID"),
ItemIDs[i]
)
);
for (int j = 0; j < FieldNames.Count(); j++)
{
xMethod.Add(new XElement("Field",
new XAttribute("Name", Functions.SPFieldName(FieldNames[j])),
Values[j]
)
);
}
xDoc.Root.Add(xMethod);
}
ls.UpdateListItems(ListName, xDoc.Root);
}
}
Upvotes: 1
Views: 2396
Reputation: 61
Use the content type name & it will work in SharePoint 2010
<Method ID='1' Cmd='New'><Field Name='Title'>134</Field><Field Name='ContentType'>ContentTypeNameHere</Field></Method>
Upvotes: 0
Reputation: 360
It seems that adding a field with name of "ContentType" and giving it a value of the content type name does work. I do not know if this is supported or not.
Upvotes: 0
Reputation: 556
There is no way to update the content type using web services for SharePoint 2010 without making a new version. The only way to make it in SharePoint 2010 is to use the client object model. The Lists.UpdateListItems can do it but once the content type is updated the new document version is added.
See for reference : these thread
Upvotes: 1