SPFX Field Customizer: how to get full path of document in document library?
-
20-01-2021 - |
Domanda
I am creating a Field Customizer to display a hyperlink in a column in a document library view following this tutorial: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/building-simple-field-customizer
I need the absolute path of the document to create the result link.
I tried several things with event.listItem.getValueByName()
but I only get values of the columns already in the view. How do I read all columns of the list item?
Soluzione
You can use event.listItem.getValueByName("FileRef")
to get the path of the document in library. This will give you a server relative URL of the file in the document library.
If you want to have an anonymous link, then you can use event.listItem.getValueByName('.spItemUrl')
. This will work for anonymous users.