Monday, January 20, 2014

Assigning External content type field column value using Client Object Model

I think I understand your problem.


In my example I have an external data column "Beneficiary Name", using a Beneficiary external content type (accessing a table of beneficiaries in a SQL table).


I want to set the "Beneficiary Name" property using the client object model. I know the name of the beneficiary but not the ID value.


It is a fairly simple solution. You just need to identify the name of the property SharePoint assigns to the ID field, in my case it is called "Beneficiary_ID". Then set the two properties as follows:


thisItem["Beneficiary_Name"] = "Charitable Trust";


thisItem["Beneficiary_ID"] = -1;


thisItem.Update();


Setting the ID property to -1 causes the server to do an automatic lookup for the ID from the value assigned to the item.


No comments:

Post a Comment