user3616544
user3616544

Reputation: 1073

PnP.js: how to get SharePoint custom lookup column value/title for files under a folder

I have files in SharePoint that have a custom lookup column referencing a list "Document Status".

Using PnP.js, I can get the files under a folder

sp.web.getFolderByServerRelativeUrl("/sites/mysite/mylib/docs").files.expand('ListItemAllFields').get();

It only returns the ID column of the "Document Status" list, but I want to get the Title column of the list. I know probably I can iterate through each file and do another query to get the Title of the lookup value. Is there a better way to get the column(s) of the lookup list? Are there any SharePoint settings I need to change?

Upvotes: 1

Views: 1536

Answers (1)

Michael Han
Michael Han

Reputation: 3655

You could expand the property like this:

sp.web.getFolderByServerRelativeUrl("/sites/test/doc2").files.expand('ListItemAllFields/FieldValuesAsText').get()

Upvotes: 1

Related Questions