cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Getting a list of SharePoint list column names

Building on this post in the PowerApps forum with a long method to get all list items, generate and parse the entire thing as a CSV table, I reviewed their method and enhanced it into a 3-step flow! 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!  

 

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_0-1656436628507.png

 

 

 

24 REPLIES 24
Ach3322
Frequent Visitor

@ryleybauer Thank you for this helpful guide! Managed to get the array with all the column names correctly.
For my use case, I have 50 choice columns with different names, but all of them have identical choices.
I'd like to dynamically check each column's value and increment a variable accordingly.
My first idea was to loop through the "column names" array and have a SWITCH On [column name] action.
I'm stuck with getting the right syntax for PA to recognize the column name from the array as a SharePoint column and not a string. 
(I have a "when an item is created" trigger and the array loop is nested inside a for each loop with "

@{triggerOutputs()?['body/value']}" from the SharePoint trigger)
Grateful for any help/insights 🙂

You are trying to increment a variable, or are you trying to increment a column's value and are having trouble mapping the update to the specific column?
The loop of column names and the switch sounds like the approach I would take. If you are updating a single column for each loop item but are updating a different column dependent on the loop item value, for each branch, add your update item step, but only set a value for the ID and the specific column you want to change, if the other columns on the step are left blank, they don't overwrite.

 

I don't think "SharePoint Column" is a type of data, it would be a string. 

If you're trying to use the name to update a column, you might have to make a raw HTTP SharePoint call so you can use plaintext to pass in the column name in the payload and the "Type" of data won't matter so you can make a single step that can set any column's value with both a dynamic column name and a dynamic value. 

If I'm not understanding your question, please clarify further. If this was helpful, please mark give Kudos to my reply.

Ach3322
Frequent Visitor

Hey @ryleybauer ! Thank you for responding so fast 🙂
Hmmm let me clarify.
We have a list with 50 choice columns, all different questions basically. All of them have the same 4 choices (nothing, low, medium, high).
Users will submit a new item form, answering these 50 questions. Each item in the list is considered a "submission". The request is to calculate the "score" of each submission and add it to another list. The score is a simple addition, 0 points for nothing, 1 for low, 2 for medium and 3 for high.

Currently my solution looks like this:
1. When a new item is created (the submission) triggers the workflow.
2. I declare some variables, like the "column names" array and "total score".
3. Your steps from the original post go here:
       i. HTTP request to SharePoint
      ii. Parse JSON
     iii. Append column names to the "column names" array

4. This is where I'm stuck:
For each (loop) item in the "column names" array, I want to check the field's value.
I tested with "hardcoding" the switch actions, I can use dynamic content and check each field individually, e.g. case 1: "field x" equals to low, increment "total score" var by 1. This works, but it doesn't feel like a good solution in the long-run.
My idea was to use the contents of the array instead of dynamic content and loop through the same switch action, instead of having 50 different switch actions. Using the display names of columns in the array, returns an empty "total score", because it cannot find columns with those names, so it always goes to the default case (no addition to the "total score")
I tried adding the StaticName or InternalName (from the Parse JSON action) in the array, but when I try this, I get "The value cannot be null. The action type 'AppendToArrayVariable' only supports values of types 'Float, Integer, String, Boolean, Object'., during the append to array variable action.

There is a 5th step, where I add the value of "total score" to another list, but nothing remarkable.

EDIT: to make it clearer, the HTTP request returns the column titles (display names) and not the internal names (with _x0020_ instead of spaces) which I seem to need to be able to execute the switch action correctly. The internal or static name produced from parse JSON action are always null and I have no clue why. 😅

While I would agree that it feels crude, a loop is really nothing computationally, just an extra API call per iteration, which can be a problem if you have lots of flows as you only get 40K/day before getting throttled.
You wouldn't need 50 different switch actions, you would need a single condition to check if it was the right type of column (i.e. value equals choice A, or value equals choice B, or choice C or choice D, and then the switch would be based on the score to decide how much to increment the variable.

How are the items being created? Are you using PowerApps or a customized list form? Then you can calculate it in the app instead of power automate to sum up all the values which would work for blanks as they wouldn't be "null" per se and would probably feel easier.
If using MS forms as a front end, then keep the approach you've described as there isn't really a way to handle that calculation that I'm aware of.

 

One other option is to go with calculated column on the list, this is kind of a good use case for it, but it would be a messy formula with 50 columns and 4 states for each condition to translate them from text to a value.

Ach3322
Frequent Visitor

Hi again @ryleybauer !
Thank you for taking the time and providing insights!
Figured out my mistake:
Added "and FieldTypeKind eq 6" in the Uri field of the "Send an HTTP request" action, so that only choice columns are returned.
And in the loop I added compose the current item of the array and then in the Switch I use "On":
item()?[Outputs(Compose)]?['Value'] 

This two seemed to do the trick 🙂

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (766)