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

Update bulk records with ForAll is not working in SQL

Hi,

i am doing simple operations. Editing gallery textinput fields and when i change value there it adds new value to _supplyTemp temprary collection.

then i want iterate through this collection and update bulk records on azure sql.

 

i use below code, but no one record are updated. what is wrong there?

 

 

ForAll(
    _supplyTemp;
  Patch(
    '[dbo].[Tiekimas]';
    LookUp('[dbo].[Tiekimas]';
    Id = _supplyTemp[@Id];
    {
        Id: Id;
        UzsakymoId: _orderId;        
        Rusiavimas: Rusiavimas;
        TiekimoKategorijosId: TiekimoKategorijosId;        
        Aprasymas: Aprasymas;
        Matas: Matas;
        Kiekis: Kiekis;
        Kaina: Kaina;
        Viso: Viso
    }
)));;
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: Update bulk records with ForAll is not working in SQL

thanks for support.

but i solved my issue following:

When edited gallery TextInput fields i did gallery data source edit

Patch(_supply;ThisItem;{Aprasymas:TextInputAprasymas.Text})

And then i make just use patch, because in this way galery data source and database table are similar:

Patch('[dbo].[Tiekimas]';_supply);;

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Update bulk records with ForAll is not working in SQL

@opit 

You appear to have a mistake in your formula, consider changing to this:

ForAll(
    _supplyTemp;
  Patch(
    '[dbo].[Tiekimas]';
    LookUp('[dbo].[Tiekimas]';
    Id = _supplyTemp[@Id]);  //<- Missing ending parenthesis here for your lookup
    {
        Id: Id;
        UzsakymoId: _orderId;        
        Rusiavimas: Rusiavimas;
        TiekimoKategorijosId: TiekimoKategorijosId;        
        Aprasymas: Aprasymas;
        Matas: Matas;
        Kiekis: Kiekis;
        Kaina: Kaina;
        Viso: Viso
    }
)));; //<- remove extra paren here

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Helper I
Helper I

Re: Update bulk records with ForAll is not working in SQL

I fixed mistake, but it was not solved issue, records to SQL database are not saved.

Highlighted
Super User
Super User

Re: Update bulk records with ForAll is not working in SQL

@opit 

Also consider removing the Id: Id; assignment from your record.  You are altering an existing record that already has an Id, there is no need to reassign that value and in some cases, can cause the record to not get updated.

If that is still not helping, try to reduce down the section of the formula that is causing the issue.  So, for example, try to execute the contents of your ForAll (the Patch statement) separately in someplace like a button.  Replace the Lookup Id=_suppllyTemp[@Id] with a known value - Id=1 for example.

See if your Patch statement is working properly outside of the ForAll.  Then, if not - fix that issue.  If so, then proceed to diagnose the issue from within the ForAll.  Review your collection in the collection viewer and make sure that it has the columns and values that you expect.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Helper I
Helper I

Re: Update bulk records with ForAll is not working in SQL

thanks for support.

but i solved my issue following:

When edited gallery TextInput fields i did gallery data source edit

Patch(_supply;ThisItem;{Aprasymas:TextInputAprasymas.Text})

And then i make just use patch, because in this way galery data source and database table are similar:

Patch('[dbo].[Tiekimas]';_supply);;

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,286)