cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dungar
Helper I
Helper I

ForAll and UpdateIf alias/conditions

I've been reading about/trying this all day, and have just given up and need someone to help figure out what i'm doing wrong.  Using an Azure SQL database when talking about tables

 

The process-

 

Step 1: User selects records from recordTable into a collection (colRecords).  This works

Step 2: User fills out a form and submits it to summaryTable (basically sums up the records + some user input).  During this varSummaryID is populated and stored in a variable.  This also works.

Step 3: OnSuccess of the submitted form, I need to update the recordTable, which has a column called "SummaryID".  I have gotten this to either not work at all, or to update EVERY record in the table (100k ish records...well it tried to.  I caught it and killed it).

 

If this were SQL the final step would be

 

UPDATE recordTable

SET SummaryID = 'SummaryIDGoesHere'

WHERE recordTable.ID IN colRecords.ID

 

Obviously not a real statement, but just trying to get the idea across.

 

My attempt-

 

 

ForAll(
    colRecords,
    UpdateIf(
        recordTable,
        recordTable.ID = colRecords.ID,
        {Stuff to update}
    )
)

 

My issue is the condition logic- recordTable.ID = colRecords.ID

This variation will not work as you can't alias like this (recordTable.ID/colRecords.Id). 

Trying:

ID = ThisRecord.ID:  is what led to the "update everything" scenario, so i assume that's just it saying ThisRecord.ID = ThisRecord.ID

 

I've also messed with patching and lookups, but 90% of the questions on this relate to other issues. My problem here is that i'm taking the starting table, getting ID's from it, then trying to update that table for every ID selected, and yet I can't seem to get it to reference the right thing.

 

1 ACCEPTED SOLUTION

Accepted Solutions
dungar
Helper I
Helper I

Finally found a video that helped.  Final code-

 

ForAll(
    RenameColumns(colRecords,"recordID","TestID"),
    UpdateIf(
        'recordTable',
        'recordTable'[@recordID] = TestID ,
        {SummaryID:varSummaryID}
    )
)

 

As i suspected it was just an aliasing issue, and i'd totally forgotten about rename columns.

 

It drives me crazy how many little edge cases like this exist, where the product is ALMOST there, but I wind up stuck replicating basic functionality, and you wind up wading into syntax/expectation hell.

View solution in original post

1 REPLY 1
dungar
Helper I
Helper I

Finally found a video that helped.  Final code-

 

ForAll(
    RenameColumns(colRecords,"recordID","TestID"),
    UpdateIf(
        'recordTable',
        'recordTable'[@recordID] = TestID ,
        {SummaryID:varSummaryID}
    )
)

 

As i suspected it was just an aliasing issue, and i'd totally forgotten about rename columns.

 

It drives me crazy how many little edge cases like this exist, where the product is ALMOST there, but I wind up stuck replicating basic functionality, and you wind up wading into syntax/expectation hell.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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