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 / Trouble with Patching
Power Apps
Suggested Answer

Trouble with Patching

(1) ShareShare
ReportReport
Posted on by 287
I have a dataverse table where the primary key is an autonumber field called Name.
 
I use Jobnumbers in my database for EACH record and when I'm ready to pay a job I want to show the jobnumbers in a gallery, then mark them all "Ready to Pay" in a field called Status in the same database.  Each record is a Purchase order (PO) to my suppliers for that Job.
 
So I made a gallery of unique JobNumbers, put a checkbox in it and in the Onselect i have this: 
//Collect(jobsToPay,ThisItem)
ClearCollect(
jobsToPay,
Filter(
'Mprinted Business Operations',
'Job Number' = ThisItem.JobNumber
)
);
This Filters all the matching PO's with the same Jobnumber and builds a collection so that I can mark them "Ready to Pay" with a Patch Command.
 
 
When testing the patch command with a hard coded value - this code works:
/*
Patch(
'Mprinted Business Operations',
LookUp('Mprinted Business Operations', Name = "3776"),
{Status: "Ready To Pay"}
)
*/
 
However, when I try to iterate the jobsToPay collection, I get this:
 
 
My thinking:
1. poRecordsToPatch - a new collection to build all the full records I need to patch.
2. ForAll - let's iterate all of the jobsToPay collection 
3. Lookup each full record in my db where the unique identifier Name matches the current record we are iterating
 
Again, Each PO record in the 'Mprinted Business Operations' db has a unique field called Name.  I thought it best to save that unique number so I could patch the exact records later, so I collected it and am now trying to use it in my iterated lookup.

I have worked on this most of the day.  Any help is appreciated.
 
I have the same question (0)
  • Suggested answer
    astrontelstar Profile Picture
    287 on at
    Got it working.
    Maybe this will help someone.
    When I built my collection of selected jobs, I converted the AutoName Primary key "Name" into a text field and saved it to jobsToPay and used that collection:
    learCollect(
    jobsToPay,
    ShowColumns(
    AddColumns(
    Filter(
    'Mprinted Business Operations',
    'Job Number' = ThisItem.JobNumber
    ),
    'NameAsText', Text(Name)
    ),
    'Job Number',
    'NameAsText',
    PO
    )
    );
     
    Also, PowerApps now uses single quotes instead of double quotes for all column names evidently.

    To Patch these, I did this....
    ForAll(
    jobsToPay,
    Patch(
    'Mprinted Business Operations',
    LookUp('Mprinted Business Operations', NameAsText = ThisRecord.cr014_name),
    {Status: "Good To Pay"}
    )
    );
     
    The whole "NameAsText" Lookup was the answer, it seems PowerApps was getting confused trying to do a lookup with
    the "Name" field from the db Dataverse table so I converted it and then sent that as a text and did the lookup that way and it worked!

     
  • astrontelstar Profile Picture
    287 on at
    Now I get this? I moved to using Logical Names from my dataverse table
     
    ForAll(
    poRecordsToPatch,
    Patch(
    'Mprinted Business Operations',
    LookUp('Mprinted Business Operations', cr014_name = ThisRecord.cr014_name),
    { Status: "Ready To Pay" }
    )
    )
     
    Simply trying to patch my db record with this new status?
  • astrontelstar Profile Picture
    287 on at
    Hmmmm.  So I'm still getting this error:
     
    with this code:
    ForAll(
    jobsToPay,
    Collect(
    poRecordsToPatch,
    LookUp('Mprinted Business Operations',Name = ThisRecord.Name)
    )
    )
     
    If I take the Lookup out and just collect ThisRecord.Name, I get 3 records with the correct string from my autonumber record field 
    that i am using for my lookup, so I know that ThisRecord.Name seems to be referring to the correct record, but the lookup doesn't like it.
     
     
     
     
     
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,719 Super User 2025 Season 2 on at
    Hi,
     
    So let me clarify something the two things you are showing are very different.
    The patch works because you are patching a single record, and you are doing a lookup to find that record. So it works. (please see below now)
     
    Patch(
    'Mprinted Business Operations',
    LookUp('Mprinted Business Operations', Name = "3776"),
    {Status: "Ready To Pay"}
    )
    */
     
    But in this case you have to change what you are doing because the output of a Forall is NOT a table, which is
    what I think you are trying to do (insert them all in batches).
     
    Change it to the below so that it will 
     
    Clear(poRecordsToPatch); // assuming this already exists. As you cannot do a ClearCollect in a ForAll

    ForAll(jobsToPay,
       Collect(poRecordsToPatch, LookUp(XXXXXXXXX));
    );
     

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
Kalathiya Profile Picture

Kalathiya 422

#2
WarrenBelz Profile Picture

WarrenBelz 380 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 325 Super User 2025 Season 2

Last 30 days Overall leaderboard