1

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

2

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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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