4

I have a list which contains a column having data type as "External Data". I want to update that particular column using CSOM. I have tried below code:

   ClientContext clientContext = new ClientContext(SharePointSiteUrl))
   Web web = clientContext.Web;
   clientContext.Load(web);
   List splist = web.Lists.GetByTitle(SharePointListName);
   ListItem oListItem = splist.GetItemById(ID);
   oListItem["ExternalDataColumn"] = "Current";
   oListItem.Update();
   clientContext.ExecuteQuery();

Here ExternalDataColumn has "External Data" data type. The Problem is where that field is empty I cannot able to set the new value. But where it contains the value and if I change that value, then it updates successfully.

I am facing the Problem with the blank values.

Any help would be appreciated.

4

Use the below code to update.

ClientContext clientContext = new ClientContext(SharePointSiteUrl))
Web web = clientContext.Web;
clientContext.Load(web);
List splist = web.Lists.GetByTitle(SharePointListName);
ListItem oListItem = splist.GetItemById(ID);
oListItem[CoulmnName] = "Current";
oListItem[ColumnRelatedField] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { "Current" });
oListItem.Update();
clientContext.ExecuteQuery();

Also refer the below link

https://blogs.msdn.microsoft.com/kaushalendra/2012/04/01/updating-external-data-column-using-client-object-model/

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.