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 am using word automation services to convert docxs to pdf. This works fine, and I add the metadata (Strings) to the resultant pdf. However, how can I add lookup value fields to the document's list item?

Item["Field"] = LookUpField[1]; (where "Field" is of type Lookup).

LookupField is a collection of type List and stores the value of the list item field from the docx value.

I get this error:

ex = {"Invalid look-up value.\n\nA look-up field contains invalid data. Please check the value and try again."}

What's the best way to do this?

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Lookup values should be either integers which represent ID of the target element in the lookup list, or strings formatted as id;#title.

For example:

item["FieldName"] = 10;
item["FieldName"] = "10;#Target item title";

Thus I would recommend you to check in debugger, what values do you have in the LookUpField collection.

Also you could try using ParseAndSetValue method, i.e.:

var field = item.Fields.GetFieldByInternalName("FieldName");
field.ParseAndSetValue(item, value);
share|improve this answer
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.