web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collect function retri...
Power Apps
Answered

Collect function retrieves value as table or missaligned

(0) ShareShare
ReportReport
Posted on by 24

Hi,

When I try to add data to my collection with the following line it saves the data as seen in figure 1:

ForAll(currentUserPresence3.value;Collect(take2TestCollection;{Presence:value.availability;ID:value.id}))

 

Figure 1:

TempUser_0-1616080694716.png

each of the cells contain what seems to be a table with 1 value insted of just containing the value itself. Here is what the first row in the presence column contains:

Figure2:

TempUser_1-1616080753451.png

And the first row in the ID column:

Figure3: 

TempUser_2-1616080860550.png

 

Alternatively I tried to run the following line of code to avoid them being stored as tables, but it also gave an unwanted result:

ForAll(currentUserPresence3.value;Collect(take2TestCollection;value.availability;value.id))

Figure 4: 

TempUser_4-1616081148154.png

 

 

the last line resulted in the values being stored on separate rows, whereas I want them to be matching up on the same row (both columns are in order, just misaligned). 

 

Any help much appreciated!

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @TempUser 

    Please consider changing your Formula to the following:

    Collect(take2TestCollection;
     ForAll(currentUserPresence3;
     {Presence: value.availability;
     ID: value.id
     }
     )
    )

    I hope this is helpful for you.

  • TempUser Profile Picture
    24 on at

    Unfortunately this gave the same result as my first attempt: 

    TempUser_0-1616082035315.png

    where each of these tables contains a single value as seen in Figure 2 and 3 in the original post

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @TempUser 

    What is currentUserPresence3?  It is obvious that the ID and Presence columns are tables.

  • TempUser Profile Picture
    24 on at

    CurrentUserPresence3 is the result of a call to a custom connector that runs getPresenceByUserId (using graph API), but I'm quite new to PowerApps so I'm not entirely sure what CurrentUserPresence3 actually looks like.

    Here is the line that calls the custom connector:

    UpdateContext({currentUserPresence3:ForAll(allUsers.value.id;'Azure-GraphAPI-CustomConnector'.GetUserPresence({ids:[id]}))})

    I do believe currentUserPresence3 looks something like this structurally though:

    TempUser_0-1616083320420.png

    please excuse my lacking Paint skills..

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @TempUser 

    No worries!   So my point made before what that you are getting tables in your ID and Presence.  This is telling me that your return results have a table in them.

    SO, if you only want the first record of that table (and it might in fact only have one), then you can change the formula I provided to this:

    Collect(take2TestCollection;
     ForAll(currentUserPresence3;
     {Presence: First(value).availability;
     ID: First(value).id
     }
     )
    )
  • TempUser Profile Picture
    24 on at

    Thanks! That seems to have done it

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard