Question

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.

Était-ce utile?

La solution

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/

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top