Search This Blog

Sunday, March 7, 2021

In SharePoint Online, using CSOM - update Workflow Tasks fields Programatically.

 

using (ClientContext ctx = new ClientContext("http://sp2016:22338/test/sites/"))

            {

                Web web = ctx.Web;

                List oList = web.Lists.GetByTitle("Workflow Tasks");

                ListItem listitem = oList.GetItemById(7407);

                ctx.Load(listitem);

                ctx.ExecuteQuery();

                Hashtable ht = GetExtendedPropertiesAsHashtable(listitem);

                listitem["Completed"] = true;

                listitem["PercentComplete"] = 1;

                listitem["Status"] = "Completed";

                listitem["WorkflowOutcome"] = "Approved";

                listitem["FormData"] = "Completed";

                //listitem["__ModerationComments"] = "Sdfs";

                //listitem["ows_FieldName_Comments"] = "Sdfs";

                //ht["ows_FieldName_Comments"] = "sdsds";

                listitem.Update();

                ctx.ExecuteQuery();

            }