cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dchandna
Level: Powered On

How to Transfer a collection with multiple rows & columns into a CDS table as is?

It would have been easier if there was a For / while loop in PowerApps. But without it I'm unable to figure out how to create records in my CDS table from my dynamic collection by click of a button. Any guidance is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: How to Transfer a collection with multiple rows & columns into a CDS table as is?

Hi @Dchandna 

 

ForAll(ColName,Patch(...{ CDSFieldName1: column1  })) 

 

or

 

ForAll(ColName,Patch(...{ CDSFieldName1: ColName[@column1]  })) 

 

both should work

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
Dual Super User
Dual Super User

Re: How to Transfer a collection with multiple rows & columns into a CDS table as is?

Hi @Dchandna 

 

You can use

 

ForAll(colName, If(Column = "test", Patch(create record in CDS or update record)))

 

Where ForAll - will loop through all items of your collection

you can also filter your collection there

 

ForAll(Filter(colName,condition),Patch(create record in CDS or update record))

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

 

Dchandna
Level: Powered On

Re: How to Transfer a collection with multiple rows & columns into a CDS table as is?

Hi Reza, Thanks for your reply.

 

For my case there is no condition as I need to transfer all the rows and columns to my table in CDS. So your solution doesnt work for me.

Super User
Super User

Re: How to Transfer a collection with multiple rows & columns into a CDS table as is?

@Dchandna 

Then why not take @RezaDorrani's suggestion and remove the conditional statement if you want to do all records?

 

ForAll(colName,Patch(create record in CDS or update record))

 

Dchandna
Level: Powered On

Re: How to Transfer a collection with multiple rows & columns into a CDS table as is?

@mdevaneyit doesnt work as I already tried it this way. May be I'm missing something there

 

I was expecting that below might work

ForAll(ColName,Patch(...{ CDSFieldName1: ColName.column1  })) 

But you get a type mismatch error like expected Text got Table. When I tried First(ColName).Column1 it works but it inserts only the 1st record multiple times. Unable to get the Collection record during the loop.

Dual Super User
Dual Super User

Re: How to Transfer a collection with multiple rows & columns into a CDS table as is?

Hi @Dchandna 

 

ForAll(ColName,Patch(...{ CDSFieldName1: column1  })) 

 

or

 

ForAll(ColName,Patch(...{ CDSFieldName1: ColName[@column1]  })) 

 

both should work

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (3,820)