3

I use CSOM and I'm trying to find a way how to change vti_contenttypeorder property for a list item.

Does anyone know some workaround how I can to do this?

0

Just for the sake of clarity, there are two properties:

ContentTypeOrder is a read-only field but if you're working with folders, you can use the property UniqueContentTypeOrder (available in CSOM) like so:

Folder.UniqueContentTypeOrder = ContentTypeOrder//maybe some additional tweaking

I actually made a working proof of concept sometime ago to change the vti_contenttypeorder property through CSOM. The UniqueContentTypeOrder property didn't work as it did not allow me to actually remove content types, just set the order.

clientContext.load(folder, 'Name', 'UniqueContentTypeOrder', 'ContentTypeOrder', 'Properties');
...
//construct the contentTypeString (comma separated string of content types)
...
var folderProps = folder.get_properties();
folderProps.set_item("vti_contenttypeorder", contentTypeString);
folder.update();
clientContext.executeQueryAsync(...);

More:

https://stackoverflow.com/questions/3979628/difference-between-contenttypeorder-and-uniquecontenttypeorder

0

I have found a workaround using lists.asmx web service

using (var listsWS = new ListsService(url, cookie))
{
    string updateXml = string.Format("<Batch OnError='Continue'><Method ID='1' Cmd='Update'><Field Name='ID'>{0}</Field><Field Name='MetaInfo' Property='vti_contenttypeorder'>0x010100E1A96B0CF4FC4C4E8EABF3AB52EED1A3</Field></Method></Batch>", itemId);
    var doc = new System.Xml.XmlDocument();
    doc.LoadXml(updateXml); 
    listsWS.UpdateListItems(list.Id.ToString(), doc.SelectSingleNode("//Batch"));
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.