How to refer to a lookup field in a returned CAML query?
-
16-01-2021 - |
Frage
I know how to refer to a standard field in the OnSuccess function of a .executeQueryAsync call using a CAML query;
qryItems.itemAt(1).get_item('Mailto')
However, I have another column that is a lookup field returned from an associated field. For example;
The field I want to reference is Preferred E-mail.
I have tried;
qryItems.itemAt(1).get_item('Preferred E-mail')
But this does not work. I have tried getting the internal field name from the URL (Field=Account%5Fx003a%5FPreferred%5Fx0020%5FE%5F) and passed it through a URL Decoder to get Account_x003a_Preferred_x0020_E_. This does seem oddly truncated and;
qryItems.itemAt(1).get_item('Account_x003a_Preferred_x0020_E_')
This works to a degree, but returns an object rather than the text of the e-mail address itself.
Lösung
Hi Have you tried using
qryItems.itemAt(1).get_item('Preferred E-mail').get_lookupValue()
Andere Tipps
For getting lookup values use below:
var columnFieldValue = qryItems.itemAt(1).get_item("columnName");
var lookupValue = columnFieldValue.get_lookupValue();
var lookupId = columnFieldValue.get_lookupId();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange