Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a CSOM console app that uploads files to a library, then it creates a lookup field in another list and also adds lookups to the files in my library.

The following code adds a single item in the lookup:

FieldLookupValue flv = new FieldLookupValue() { LookupId = Convert.ToInt32(attachmentFile.Id) };
listItem["MyAttachments"] = flv;

How can i modify this to add multiple FieldLookupValue's?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Try the following:

Create a List of FieldLookupValue's

List<FieldLookupValue> lookupValues = new List<FieldLookupValue>();

Add a new FieldLookupValue for each file id

lookupValues.Add(new FieldLookupValue() { LookupId = Convert.ToInt32(attachmentFile.Id) });

When finished set the listItem to the List

listItem["MyAttachments"] = lookupValues;

Hope this works for you!

share|improve this answer
    
Hi Tom, thanks so much for the assistance. That worked perfectly for me. So simple. Im embarassed i didnt see that solution myself. –  Cobus de Witt Jun 26 '13 at 6:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.