You cannot change moderation status and set other item properties at that same time SharePoint online


In this post we will discuss how we can resolve the below issue which comes when trying to update the Approval status column as well as some properties of the list item in SharePoint online using csom ( .Net managed object model code).

Recently we were working on a SharePoint project where we need to update item properties of a list item where we also need to update the approval status of the item using csom (.Net managed object model code). We were trying the below code:


if (item != null)

{

item[“Columnname”] = “Column Value”;

item[“Columnname 1”] = “Column 1 Value”;

item[“Columnname 2”] = “Column 2 Value”;

item[“_ModerationStatus”] = “0”;

item.Update();

context.ExecuteQuery();

}

In the ExecuteQuery() method it gave the below error:

You cannot change moderation status and set other item properties at that same time.




Solution:
We changed the code like below. Basically we change first update the item custom column properties and then we change the _ModerationStatus properties value.

if (item != null)

{

item[“Columnname”] = “Column Value”;

item[“Columnname 1”] = “Column 1 Value”;

item[“Columnname 2”] = “Column 2 Value”;

item.Update();

context.ExecuteQuery();

item[“_ModerationStatus”] = “0”;

item.Update();

context.ExecuteQuery();

}

Read some sharepoint online tutorials:

After this the error did not come. Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now

EnjoySharePoint YouTube Channel

About Bhawana Rathore

Hello Everyone!! I am Bhawana a SharePoint MVP and having about 8+ years of SharePoint experience as well as in .Net technologies . I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools . Now exploring more in SharePoint 2016 :) Hope here I can contribute and share my knowledge to the fullest. As I believe "There is no wealth like knowledge, and no poverty like ignorance"

View all posts by Bhawana Rathore →