Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Programatically insert/update lookup field with data from external list

$
0
0

Hi

I have a SharePoint list called Products which has many Look Up column. I also have multiple external lists which I use for the look up fields in Products list. I am at a stage where I have to import 1000+ items into Products list programmatically. Here is what i have so far.

var client = new Microsoft.SharePoint.Client.ClientContext("http://intranet.ltp.org/products");
var list = client.Web.Lists.GetByTitle("products");
var newItem = new ListItemCreationInformation();
var newListItem = list.AddItem(newItem);

newListItem["Item_x0020_Code"] = "3DR"; //Text field
newListItem["Vendor"] = ??? //Vendor is a lookup field that uses an external list. I tried setting the field with a text value, but it goes away when I edit the record after being recorded. I tried setting the BdcIdentity of the actual value, but that goes away when i edit the record as well.

newListItem.Update();
client.ExecuteQuery();

Can someone point me to the right direction? Or is there a work around to get look up field value that uses external list data programatically?

Any help would be really appreciated.

Thank you,

Amal


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>