0

I am changing the content type of pages using CSOM and would like to preserve the modified by field as it is. The issue is I can set the modified by value to original value, but as soon as I publish the page it changes.

        var listItem = pagesLibrary.GetItemById(record.ListItemID);


        /// Get the page from the Pages library.
        Microsoft.SharePoint.Client.File page = listItem.File;

        /// Load the document.
        clientContext.Load(page);

        //Load the requested list item
        clientContext.Load(listItem,
                         item => item["Title"],
                         item => item["Author"],
                         item => item["Editor"],
                         item => item["Created"],
                         item => item["Modified"],
                         item => item["_ModerationStatus"]);

        clientContext.ExecuteQuery();  

        listItem["Author"] = newAuthorFieldUserValue;        

        listItem["Editor"] = editorUserValue;

        listItem.Update();

        clientContext.ExecuteQuery();

        clientContext.Load(page);
        listItem.File.Publish("Published");
        clientContext.ExecuteQuery();
1

With CSOM package 16.1.5626.1200 list item has SystemUpdate method.No need to checkout the page when updating pages and when updating they are not getting unpublished as well.

https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-august-2016-updated

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.