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

Possible "LookUp" bug in "ForAll" function for combobox when LookUp and combobox use the same table & same column

I have a SQL table "platform" <ID, descriptions>, where ID is an auto-increment value. I set up a combobox in PowerApps using the descriptions as choices. Then I would like to get the selected item ID. The original function I use is 

```

ClearCollect(colPlatform, {var1, platform_ID});

ForAll(combobox.SelectedItems, Collect(colPlatform, {var1: ..., platform_ID: LookUp(platform, descriptions = descriptions, ID)}))

```

The first "descriptions" is the platform table column. The second "descriptions" is the combobox item values. Turns out the ID is always 1 whatever the original ID should be.

To avoid this problem, I created a temporary collection using a different name from "description" to collect item values in combobox, then use the new collection to substitute the function of combobox.SelectedItems to get the correct ID results.

 

May I know if there is a better way to avoid such operation? Is this a bug or if there is something wrong with my previous code?

 

Thank you.

fromage

1 ACCEPTED SOLUTION

Accepted Solutions
BCLS776
Super User
Super User

Scope management can be difficult with ForAll statements. Try:

ClearCollect(colPlatform, {var1, platform_ID});

ForAll(combobox.SelectedItems As aItem, 
    Collect(colPlatform, 
    {
        var1: ..., // with the other required entries
        platform_ID: LookUp(platform, descriptions = aItem.descriptions, ID)
    }
    )
)

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
BCLS776
Super User
Super User

Scope management can be difficult with ForAll statements. Try:

ClearCollect(colPlatform, {var1, platform_ID});

ForAll(combobox.SelectedItems As aItem, 
    Collect(colPlatform, 
    {
        var1: ..., // with the other required entries
        platform_ID: LookUp(platform, descriptions = aItem.descriptions, ID)
    }
    )
)

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

fromage
Frequent Visitor

Hi Bryan,

 

Thank you for the quick response. You are brilliant! This indeed works! I do not know this grammar before.

 

Thank you! 🙂

fromgae

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,284)