1
votes

I have a custom web part that I can connect to different data sources (e.g SharePoint Document Libraries). Then I can map the item properties from that document library to one of my different view templates.

The problem is when I add a Link item (external Url) in that document library, I cannot find an item property that stores that external Url.

enter image description here

Right now I get the item properties via SharePoint REST API. I checked the values for FileRef and EncodedAbsUrl, but these are URLs pointing to the SharePoint document library file, and not to the external URL.

After some investigations, I've seen in the dev tools (F12) Network tab, there's a call to https://{siteurl}/_api/SP.Utilities.ShortcutLink.GetShortcutLink(@a1)?@a1={siteUrl}/Shared%20Documents/www.dummysite.com.url which will retrieve the actual linked external URL, but this not a good option for me, since making another REST call for each item will impact my performance.

So is there any item property that I could expand to get the external URL, via REST API?

1

1 Answers

0
votes

You can extract properties for specific item and then select "vti_x005f_shortcuturl" property. E.g.

    https://<your site url>/_api/web/lists/getbytitle("your library 
    name")/items(1)/properties?$select=vti_x005f_shortcuturl 

If you don't have item id in advance then first get only Id's from document library using rest api in first call as you are concerned with performance if you have to call rest api twice, and then call above api for each item ID with required properties only. In above example it will return url behind link for first item ("/items(1)/") if available.