0

How to upadate only non read only fields of a SharePoint list using client object model? The code sample is working fine for a particular field like title

        string siteUrl = "http://MyServer/sites/MySiteCollection";
        ClientContext clientContext = new ClientContext(siteUrl);
        SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");
        ListItem oListItem = oList.Items.GetById(3);
        oListItem["Title"] = "My Updated Title.";
        oListItem.Update();
        clientContext.ExecuteQuery();

But I have an array containing values of all fields of the list and want to update all non read only fields of the list(not a particular field like title) using client object model. Any code example or suggestion is highly appreciated.

1

You can get the fields collection from CSOM

SP.List oList = clientContext.Web.Lists.GetByTitle("List Title Here"); 
SP.FieldCollection fieldColl = oList.Fields;
clientContext.Load(fieldColl);
clientContext.ExecuteQuery();

After that you can check the "ReadOnlyField" Property of the field.

OR

Field field = list.Fields.GetByTitle("Title");
clientContext.Load(field);

Then check field.ReadOnlyField property

Also Check here

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.