Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
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.
Categories:
  • NPPlatform Profile Picture
    606 Super User 2025 Season 1 on at
    Re: Patching a LookUp not working

    Understandable, glad you got it working!

  • NthnClrksn Profile Picture
    10 on at
    Re: Patching a LookUp not working

    @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 Super User 2025 Season 1 on at
    Re: Patching a LookUp not working

    @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'
    )

     

  • Verified answer
    NPPlatform Profile Picture
    606 Super User 2025 Season 1 on at
    Re: Patching a LookUp not working

    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'

                    )

                )

            }

        )

    )

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Microsoft Dataverse

#1
mmbr1606 Profile Picture

mmbr1606 22 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 17

#3
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

Overall leaderboard

Featured topics