Search code examples
listsharepointhyperlinkpowerappsdisplayname-attribute

How do I get the display name of a hyperlink that comes from SharePoint in Power Apps?


In a list located in SharePoint, that has over 100 items, there are 5 hyperlink columns, with each entry in it including the URL address and a display name.

I am creating a form for this list that allows the user to edit both the URL and the display name, but I can't seem to reference the display name of hyperlink columns.

How do I do that?

Here is the form made in Power Apps

The hyperlink columns have display names that were covered in blue. I need to get them in Power Apps


Solution

  • Yes, it's possible! Not with the built-in SharePoint connector, but with an HTTP request with the standard (not premium!) Office 365 Groups connector and the Graph API.

    Let's go!

    Step 1

    Create a SharePoint list with an hyperlink column.

    Create a new item with a Title, an URL and the URL Description:

    list item with an URL

    Create more items... SharePoint list

    The goal is to display the URL description, not the Title in a PowerApps Canvas. Unfortunately with the SharePoint connector, only the title and URL are returned. Not the URL description. For example, with a simple gallery the result is:

    Gallery with the SharePoint Connector

    But there is a simple solution!

    Step 2

    In your Power Apps Canvas, create a new connection with the Office 365 Groups connector.

    Step 3

    In your Power Apps Canvas, open App > OnStart and write this expression (replace YOUR-SITE-GUID by your site GUID). The sample is written for an English Power Apps Studio (it not, change the , and ; according to your language: https://learn.microsoft.com/en-us/power-platform/power-fx/global#formula-separators-and-chaining-operator)

    To get YOUR-SITE-GUID, you can call this simple web request https://your-tenant.sharepoint.com/sites/your-site/_api/site/id in your browser (with your tenant and site name of course.)

    Set(AllFavorites, Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/sites/YOUR-SITE-GUID/lists/Favorites/items?expand=fields", "GET", ""));
    
    ClearCollect(
        colAllFavorites,
        ForAll(
            Table(AllFavorites.value),
            {
                Title: Text(Value.fields.Title),
                Url: Text(Value.fields.Bookmark.Url),
                Description: Text(Value.fields.Bookmark.Description)
            }
        )
    );
    

    App On Start

    Now, you have a new collection (colAllFavorites) with the title, URL and URL description!

    Step 4

    You can create a new gallery with the collection colAllFavorites as the gallery's datasource and use the description as the title of each card. The gallery is only here to display the results (for this demonstration). Fell to free to adapt to your project (with a dropdown list instead of a gallery, etc.)

    Gallery with URL description

    Conclusion

    The SharePoint GetItems connector does not return the description of an hyperlink column. The SharePoint API (Graph API or REST API) does indeed return this value! In Power Automate, SharePoint HTTP action can be used but in Power Apps it's easier to use the Office 365 Groups HTTP action (standard connector).