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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patching a LookUp not ...
Power Apps
Answered

Patching a LookUp not working

(0) ShareShare
ReportReport
Posted on by 10

I am trying to patch multiple rows of a gallery to a dataverse table. I am having issues patching to the column that is a lookup.

 

Each item is added to galley by filling in the following:

NthnClrksn_0-1710238644904.png

 
The button adds the information to a collection which is used to drive a gallery that shows the following:
 
NthnClrksn_1-1710238752500.png

 

The item number comes from a combobox and it is added to the gallery using:

 

{
            'Item Number': comboItemNumberTest.Selected.'Item Number',
}
 
When I then try to patch all of the values in the gallery table to the dataverse table. It does not patch the correct value. This is the code I use:
 
ForAll(
    glyItemsForTesting_3.AllItems,
    Patch(
        'Testing Items',
        Defaults('Testing Items'),
        {
            Available: 'Available (Testing Items)'.Yes,
            'Batch Number': ThisRecord.'Batch Number',
            Source: ThisRecord.Source,
            'Item Number LookUp': First(
                Filter(
                    'Item Designs',
                    'Item Number' = ThisRecord.'Item Number'
                )
            )
        }
    )
)
 
It is instead giving me the same item number for every case (the first item in the table) which means the filter is not working
 
I am however able to upload one at a time by patch the item that is selected in the gallery:

    Patch(
    'Testing Items',
    Defaults('Testing Items'),
    {
        Available: 'Available (Testing Items)'.Yes,
        'Batch Number': glyItemsForTesting_3.Selected.'Batch Number',
        Source: glyItemsForTesting_3.Selected.Source,
        'Item Number LookUp': First(
            Filter(
                'Item Designs',
                'Item Number' = glyItemsForTesting_3.Selected.'Item Number'
            )
        )
    }
)
 
 
It seems to me that "ThisRecord" does not work for this but I can't figure out why.
 
I also tried doing the for all for the collection instead of the gallery but the same thing happened.
I have the same question (0)
  • Verified answer
    NPPlatform Profile Picture
    606 Moderator on at

    Hi @NthnClrksn , my first suggestion would be to try and use an As-statement. This helps specify what you exactly mean with 'ThisRecord'. It might solve this issue for you. The code then would be:

     

    ForAll(

        glyItemsForTesting_3.AllItems As ItemsToPatch,

        Patch(

            'Testing Items',

            Defaults('Testing Items'),

            {

                Available: 'Available (Testing Items)'.Yes,

                'Batch Number': ItemsToPatch.'Batch Number',

                Source: ItemsToPatch.Source,

                'Item Number LookUp': First(

                    Filter(

                        'Item Designs',

                        'Item Number' = ItemsToPatch.'Item Number'

                    )

                )

            }

        )

    )
  • NPPlatform Profile Picture
    606 Moderator on at

    @NthnClrksn In addition: why do you use the First(Filter())-combination instead of LookUp? For example like:

    LookUp(
        'Item Designs',
        'Item Number' = ItemsToPatch.'Item Number'
    )

     

  • NthnClrksn Profile Picture
    10 on at

    @NPPlatform 

    Thank you for your help!

     

    I do that at the moment because some of the records are duplicated so the lookup would not give a definite answer.

  • NPPlatform Profile Picture
    606 Moderator on at

    Understandable, glad you got it working!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard