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?

  • can you check with event.listItem.getValueByName("FileRef") ? – Gautam Sheth Jul 20 '18 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 Jul 20 '18 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 – Gautam Sheth Jul 20 '18 at 15:36
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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.