Get List Item Field Details using JSOM

Due to the different types of fields used in list items there are several different techniques that can be used:

SP.ListItem.get_contentType() – Retrieves the name of the content type of a list item

SP.ListItem.get_displayName() – Retrieves the display name of a list item

SP.ListItem.get_id() – Retrieves the id of a list item

SP.ListItem.get_item(‘{InternalFieldName}’) – Retrieve the value

SP.ListItem.get_item(‘{InternalFieldName}’).get_url() – Retrieve an associated url value if the field type is hyperlink

SP.ListItem.get_item(‘{InternalFieldName}’).get_description() – Retrieve the description associated with the field

SP.ListItem.get_item(‘{InternalFieldName}’).get_lookupValue() – If the field is a person field or any other type of lookup, get the lookup value

SP.ListItem.get_item(‘{InternalFieldName}’).get_lookupID() – If the field is a person field or any other type of lookup, get the lookup id

I the above examples replace {InternalFieldName} with the internal name of a field.

Further reading

There are many other types of field and to delve deeper into the methods available, refer to the MSDN entries for the SP.Field{Type}.  The get_item() function will return an object of the appropriate type for the field.


MSDN: SP.ListItem

MSDN: SP.Field

MSDN: SP.FieldLookupValue

MSDN: SP.FieldUrlValue

Leave a Reply

Your email address will not be published.