cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
3tsolutions
Advocate II
Advocate II

How get columns name from sharepoint list

I've been looking for a way to have the column names of a SharePoint list so that I don't have to type them manually; I didn't find ready-made solutions, so I decided to create a custom solution for the purpose.

 

I created a flow with power automate, which can be trigger from PowerApps, in which it is requested:

  • the SharePoint site,
  • the name of the list
  • if you want all the columns or if you want to filter the reserved SharePoint columns

 

Step 1 ) Build an instant cloud flow and Choose how to trigger this flow with PowerApps

Step 2) Use Compose to ask in PowerApps 3 inputs:

  • the SharePoint site,
  • the name of the list
  • if you want all the columns or if you want to filter the reserved SharePoint columns (filter_enable)

1.jpg

 

Step 3) Get items from SharePoint list and use the first two Compose Inputs , limit the count to 1 and choose to use all columns list

Then Create a CSV Table , using the list of elements

 

 

 

outputs('Get_items')?['body/value']

 

 

 

2.jpg

 

Step 4) Define the variables that we will have to use in the flow

  1. The identification of CR

 

 

decodeUriComponent('%0A')​

 

 

  • The headers of the CSV Table

 

 

first(split(body('Create_CSV_table'),outputs('Compose_NewLine')))​

 

 

  • The string columns_name_filtered
  • The string columns_name

3.jpg

 

 

 

 

Step 5) Let's check that the third input defines to enable column filters

 

If NO just set the variable columns_name with the headers

if YES we need to exclude all column names reserved by SharePoint

4.jpg

 

Step 6) For each headers

 

 

 

split(variables('headers'),',')

 

 

 

exclude the reserved name, than set the variable columns_name with a columns_name_filtered

 

 

 

substring(variables('columns_name_filtered'),0,sub(length(variables('columns_name_filtered')),1))

 

 

 

we use a substring to eliminate the comma at the end of the filtered string

5.jpg

 

Step 6bis) to exclude the names of the reserved columns we use a control in OR condition,

than append the filtered columns to the variable columns_name_filtered with a comma

concat(item(),',')

6.jpg

 

Step 7) finally we send the response to PowerApps

7.jpg

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @3tsolutions ,

 

Thank you for sharing the solution which is great helpful for the community.

 

So could you consider leave a reply then accept it as the solution to help other members find it?

 

Best regards,

Community Support Team _ Jeffer Ni

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

4 REPLIES 4
v-jefferni
Community Support
Community Support

Hi @3tsolutions ,

 

Thank you for sharing the solution which is great helpful for the community.

 

So could you consider leave a reply then accept it as the solution to help other members find it?

 

Best regards,

Community Support Team _ Jeffer Ni

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

ravi_0111
New Member

@3tsolutions Hi, I am new to power apps, How do we run this flow or how to call this flow from Powerapps

AlexinEdmonton
Advocate I
Advocate I

Thank you so much for posting this solution! I thought I'd throw in my adaptation of your solution which gives me the column names in the Flow a bit quick for a simple copy and paste: After the step that gets the "column names filtered" which gives the string with all items, I just added a new array variable that splits on the ',':

AlexinEdmonton_0-1649359881459.png

which when run gives us the internal column names in a list that's relatively easy to copy and paste into whatever formula:

AlexinEdmonton_1-1649359967478.png

 

Cheers,

 

ryleybauer
Resolver II
Resolver II

Thanks for sharing this! 

 

I reviewed your method and was going to try it this way, but then I went down the rabbit hole of wondering if it was exposed via an endpoint, and sure enough, it is! Instead of using a CSV, I'll just use a SharePoint HTTP action, append array action to create the table of columns! If you like my 3-step flow, please mark it as a second solution! 

 

1. HTTP request to SharePoint:

   a. Site Address: team site URL, not root site URL

   b. GET

   c. URI: /_api/web/lists/getbytitle('LISTNAME')/fields?$filter=Hidden eq false and ReadOnlyField eq false

           - Also, the filter above takes care of all of the reserved columns except for "Content Type" and "Attachments", which could be removed by changing the URI to: /_api/web/lists/getbytitle('LISTNAME')/fields?$filter=Hidden eq false and ReadOnlyField eq false and Title ne 'Content Type' and Title ne 'Attachments'

2. Run the flow/perform this request to get a sample payload

3. Add Parse JSON step, using the body from the previous step and paste in the sample payload in the "Generate from sample" option

4. Append "Title" to an array variable inside of an Apply to Each loop based on "results"

 

ryleybauer_1-1656435434071.png

 

 

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.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

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

Top Solution Authors
Top Kudoed Authors
Users online (4,132)