cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fxavier
Frequent Visitor

Is it possible to get all column names from a sharepoint list?

As topic, is there a way to show all column name from a sharepoint list? maybe a function that can generate a collection that contain all column name from a SP list?

13 REPLIES 13
3tsolutions
Advocate II
Advocate II
AlexinEdmonton
Advocate I
Advocate I

I'd recommend using Power Automate to get the column names. I got the idea how to solve using @3tsolutions 's post here: https://powerusers.microsoft.com/t5/Building-Power-Apps/How-get-columns-name-from-sharepoint-list/m-...

 

Here's the gist:

1. Get Items from your list (Top Count = 1).

2. Create CSV table (Columns = Automatic).

3. Create Variable that is a string of the headers.

4. Create an Array variable from the string of headers:

AlexinEdmonton_3-1649368269223.png

Here are the expressions you'll need:
Compose Newline: decodeUriComponent('%0A')
Headers: first(split(body('Create_CSV_table'),outputs('Compose_Newline')))
Column Names: split(variables('headers'),',')
 

When run will give you this output that contains all the column titles. You can copy from the output and paste into your formula (clean the list as needed)

AlexinEdmonton_2-1649368179665.png

Paste into PowerApps with column names cleaned as required (I had to remove a few that were causing errors and some others I didn't want):

 

AlexinEdmonton_4-1649368858857.png

 

Takes a few minutes to set up but is worth it to get the column names especially if you need to write out (for e.g.) 50 columns.

 

Cheers,

 

PrachiM
Frequent Visitor

Try this code, to retrieve all column names from SharePoint List. This worked for me.

 

Set the variable in OnVisible action for the screen and add the variable as a datasource for the dropdownlist.

Set(
     ColumnNames,
     Distinct(
         Ungroup(
             MatchAll(
                 JSON(
                     SharePointListData,
                     JSONFormat.IgnoreBinaryData & JSONFormat.IgnoreUnsupportedTypes
                 ),
                 "([^""]+?)""\s*:"
             ).SubMatches,
             "SubMatches"
         ),
         Value
     )
 )

 

Please mark as answer, if this helps.

MarkCDWNR
Frequent Visitor

Hi,

the easiest way is to export your Sharepoint list as a csv or excel file.
then you can simply open the export file, copy the names as test a there you have it.

🙂

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,376)