cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jkling
New Member

Problem with ForAll and Patch

Good Afternoon,

 

I need a little help.  I've followed the instructions from this document and I'm not getting errors in my code, but there is no data being written to my SP list.

https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

The code below builds a collection when a user enrolls in a particular course.  The collection (colEnrollItems) is a list of records filtered by the users' email address (GvarUserEmail) and the TrainingKey (galCourseDetails.Selected.TrainingKey) which is a specific training course for which they are registered.  There was a bug that introduced duplicates into my dataset and my current patch process was only updating the first record.  I need to update all records that might exist in the dataset for this email and training key combo. 

This code is supposed to compare the source file (Training - Master Output).ID to the "NewID" in the before mentioned collection.  It will update three fields in the source file and loop through all of the records picked up in the collection. 

 

ClearCollect(colEnrollItems,AddColumns(Filter('Training - Master Output',TrainingKey = galCourseDetails.Selected.TrainingKey,SelfEmail = GvarUserEmail),"NewID",ID));
ForAll(colEnrollItems,
    Patch('Training - Master Output',
        LookUp('Training - Master Output',ID in colEnrollItems.NewID),
        {
            ScheduleID: ThisItem.ID,
            OfferingChosen: 1,
            Registered:1
        }
    )
)

 

I am not getting any errors in the code.  The problem is that the patch isn't writing to the SP list at all.  I've tried using both options below and neither of them worked. 

 

LookUp('Training - Master Output',ID = colEnrollItems.NewID)

LookUp('Training - Master Output',ID = colEnrollItems[@ID])

 

I'm at a loss, I would love some ideas from the community.  

Thanks!

Joe

 

 

0 REPLIES 0

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,165)