cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Patch multiple records

I need to patch or insert certain fields for every record in a collection, into a datasource. Meaning, FOR all records in my collection, insert an individual record with certain fields into some datasource.

 

Her is my collection: coll.FieldA, coll.FieldB, coll.FieldC

 

I need to do a ForAll(coll, patch(DATASOURCE, {datasource.fieldA: coll.FieldA, datasource.fieldB: coll.fieldB}))

 

HOW can this be done? CAN it be done?!?!?

5 REPLIES 5
Highlighted
Advocate II
Advocate II

Re: Patch multiple records

Heres what i am trying to get to work. Basicall I concat a string of a bunch of records, and then use collect to add it all to a datasource... kinda silly

 

UpdateContext(recordsToSubmit: Concat(coll, "{Datasource.FieldA: " & FieldA & ", Datasource.FieldB: " & FieldB "}, ")}); UpdateContext({recordsToSubmit: Left(recordsToSubmit, (Len(recordsToSubmit) - 2))}); collect(Datasource, recordsToSubmit)

 

What this does, is it makes recordsToSubmit a string that looks like, "{datasource.fieldA: fieldA, Datasource.FieldB: fieldB}, {datasource.fieldA: fieldA, Datasource.FieldB: fieldB}, {datasource.fieldA: fieldA, Datasource.FieldB: fieldB}" for how ever many records you have, but when you pass a variable as the "records" to the collect function, it does not run.... HELP

Microsoft
Microsoft

Re: Patch multiple records

This might help you:

ForAll(Records, Collect(NewRecords, Concatenate("{Datasource.FieldA:",FieldA,"Datasource.FieldB:",FieldB,"}") ))
Highlighted
Community Support
Community Support

Re: Patch multiple records

Hi @Bri,

 

Use forall and the patch function should work.

But in order to distinguish column name between collection and datasource, here we would use renamecolumns function to rename the column name in collection.

Please take a look at the following example:

patch multiple records which include lookup field

In your scenario, we should also take use of the renamecolumns function three times (depends on the field you would like to patch with):

ForAll(
   RenameColumns(
      RenameColumns(
               RenameColumns(Collection,"FieldA","FieldA1"),
                   "FieldB","FieldB1"),
                  "FieldC","FieldC1"),
   Patch(Datasource,
         Defaults(Datasource),
         {FieldA: FieldA1,FieldB:FieldB1,FieldC: FieldC1}
        )
  )

The formula above would add new records for each records in the collection.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate II
Advocate II

Re: Patch multiple records

Hi, when I utilize a collection where don’t have group this formula works, but in my case, I have a collection where one field is a group, so when I try to add records in database, the system show an error message some like that “the field X was waiting an number type. Type found is Table”.

 

For example, to show this collection in a gallery I have this command:

 

Ungroup( Cl_CalendActivid;"IDActividad")

 

So I try to replace collection by Ungroup command, but also didn’t work:

 

ForAll(

   RenameColumns(

     RenameColumns(

               RenameColumns(Ungroup( Cl_CalendActivid;"IDActividad"),"FieldA","FieldA1"),

                   "FieldB","FieldB1"),

                 "FieldC","FieldC1"),

   Patch(Datasource,

         Defaults(Datasource),

         {FieldA: FieldA1,FieldB:FieldB1,FieldC: FieldC1}

       )

)

 

Could you help with this issue?

 

PS: It’s possible create a collection ungrouped? The command that I utilize is (where have N lines at Gallery_CalendActvAbiert.AllItems to one line in IDCalendario):

 

ClearCollect('Cl_CalendActivid';

{IDCalendario: 1;

 IDActividad:  ShowColumns(Filter(Gallery_CalendActvAbiert.AllItems;Checkbox1.Value = true);"IDActividad")}

)

 

Thanks in advance.

 

Pierre

Highlighted
Anonymous
Not applicable

Re: Patch multiple records

Hi am creating an app where i have set password page, i want a user to be able to set there own password and get the flexibility to update it from the datasourse using the power app

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

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

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

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!

Top Solution Authors
Top Kudoed Authors
Users online (10,045)