Get SharePoint Column Descriptions into a PowerApps Form

Get SharePoint Column Descriptions into a PowerApps Form

Within a SharePoint list, it’s common practice to add a description to your columns. Naturally, you would want to provide a description to aid users in filling out the form. The out of the box form experience in a SharePoint list will display descriptions automatically. However, if you’re building a Canvas PowerApp using the Form control, you’ve probably noticed the descriptions are missing. Frustrating!

The description fields are present in the default SharePoint list form.
The same list connected to a PowerApps Form…no descriptions show. 😐

To address this limitation, I’ve seen some workarounds—like hardcoding the description directly into the form, or using a separate list to store column names and their descriptions and then using a lookup to fetch them. But to me, these approaches aren’t ideal, as it requires manual updates in the app, or maintaining duplicate descriptions outside the main list should they change.

Surely there must be a more dynamic way to fetch column descriptions. As it turns out, there is—thanks to the Office 365 Groups connector, the Graph API, and a bit of PowerFx!

Adding a Description to a SharePoint Column

Let’s quickly review how to add a description to a SharePoint column, in case you’re not already familiar with the process. Within your SharePoint list at the top-right corner, click the gear icon and select List settings. You’ll see a list of all the columns. Click on the column you want to update, enter your desired description, and don’t forget to click OK at the bottom to save your changes.

Fetch the List Metadata in PowerApps with Office 365 Groups Connector

It might seem a bit unusual to use the Office 365 Groups connector—after all, we’re not trying to retrieve group information. So what gives? Crucially, this connector supports making HTTP requests to the Microsoft Graph API. This is the ticket!

Add the Office 365 Groups Connector to your app

Using this, we can query the Graph API for details about the SharePoint site and its lists. First, we call the /sites endpoint to get the unique ID of the site. Next, we then fetch the lists associated with the site’s unique Id. Finally, we identify the list we want to use and call the /columns endpoint, which returns all the columns in the list—including their internal names and descriptions!

With that data in hand, we store it into a collection for reference.

Site Internal Name: “Sandbox”. Internal List Name “Issuetracker”

Place this PowerFx Code in the OnStart Property of your app:

// Define the Site and List's Internal Name, NOT DisplayName in the variable
Set(
    varSharePointSiteInfo,
    {
        SiteName: "Sandbox",
        ListName: "Issuetracker"
    }
);
// Query Graph API to get SharePoint Site ID
Set(
    varSiteData,
    Office365Groups.HttpRequest(
        "https://graph.microsoft.com/v1.0/sites?search=" & varSharePointSiteInfo.SiteName,
        "GET",
        ""
    )
);
// Returns an array so get the first site id
Set(
    varSiteID,
    First(Table(varSiteData.value)).Value.id
);
// Next, need to query the lists on that site
Set(
    varListData,
    Office365Groups.HttpRequest(
        $"https://graph.microsoft.com/v1.0/sites/{varSiteID}/lists/?$select=id,description,name",
        "GET",
        ""
    )
);
// Collect the Site's List ID and Internal Names into a collection
ClearCollect(
    colSharePointListData,
    ShowColumns(
        AddColumns(
            Table(varListData.value),
            'ListID',
            Text(ThisRecord.Value.id),
            'ListInteralName',
            Text(ThisRecord.Value.name)
        ),
        ListID,
        ListInteralName
    )
);
// Get the List ID for the specific one defined in varSharePointSiteInfo.ListName variable
Set(
    varListID,
    LookUp(
        colSharePointListData,
        ListInteralName = varSharePointSiteInfo.ListName
    ).ListID
);
// Finally, we can query the list to get the columns:
Set(
    varColumns,
    Office365Groups.HttpRequest(
        $"https://graph.microsoft.com/v1.0/sites/{varSiteID}/lists/{varListID}/columns",
        "GET",
        ""
    )
);
// Collect the Column Names and Descriptions
ClearCollect(
    colSharePointColumnData,
    ShowColumns(
        AddColumns(
            Table(varColumns.value),
            'ColumnDescription',
            Text(ThisRecord.Value.description),
            'ColumnName',
            Text(ThisRecord.Value.name)
        ),
        ColumnDescription,
        ColumnName
    )
);

Configure the PowerApps Form

Within each datacard property is a value called “DataField”. This value corresponds to the internal column. This value will be unique, since a list cannot have more than of the same internal column name. Then, to bring the description into the form, use a lookup formula against the column collection:

LookUp(colSharePointColumnData,ColumnName = Parent.DataField).ColumnDescription

For my text-based columns, I bring the description into the “HintText” property of the TextInput Control within the datacard. For the DatePicker and Dropdown controls, I used the “InputTextPlaceholder” property. You could just as well add a custom label control into each datacard and make the Text property the lookup formula.

And there you have it! If the description ever needs updating, just update it from the list back-end and the next time the PowerApp is refreshed, it’ll automatically pull the latest descriptions.

Leave a Reply