2

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?

3
  • can you check with event.listItem.getValueByName("FileRef") ? Commented Jul 20, 2018 at 13:06
  • Thank you that works! Its the relative URL, but I can use that. Weird enough FileRef is not in the event.listItem.fields array.
    – elsni
    Commented Jul 20, 2018 at 13:36
  • Cheers, happy to help. Have posted that as answer :) , you can accept it by ticking the checkmark besides the answer , like this Commented Jul 20, 2018 at 15:36

1 Answer 1

3

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.

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.