3

I am struggling with grabbing the text from a lookup column. The field contains a link with text, and in my JS code, I would like to access the field's text contents (not the link).

If I use oListItem.get_item("columnName"), the return value is an object (console prints [Object object]). I noticed on some forums, there was a method get_fieldValuesAsText(). Link here

This method, in theory would return the text value in the column in question. My question, is will this work, and, where can I find some examples of using this.

1 Answer 1

5

For getting lookup value use this:

var columnFieldValue = oListItem.get_item("columnName");
var lookupValue = columnFieldValue.get_lookupValue();
var lookupId = columnFieldValue.get_lookupId();
3
  • When i added this line it says get_lookupValue() isn't a function? Commented Aug 18, 2016 at 16:01
  • is field "columnName" lookup? Or it has another type? If it's hyperlink type use .get_description() and .get_url() Commented Aug 19, 2016 at 6:10
  • it only worked like this: Picture += oListItem.get_item("PictureName").get_lookupValue(); Commented Aug 19, 2016 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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