web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding Column from Dat...
Power Apps
Answered

Adding Column from Datatable in PowerApps to different Table in CDS - using Forall records and Patch(?)

(0) ShareShare
ReportReport
Posted on by 216

Hello,

I want with a push of a button let user create new record in one of my tables, from different Datable which I have filtered in Canvas App.

Ive tried this:

ForAll(DataTable2.Subtitle, Patch( HereWeDownloadIDS, Defaults( HereWeDownloadIDS ), { IdOfDownloadedItem
: DataTable2.Subtitle } ))

Received error:

Z_Lukowski_0-1611789353746.png'

And also Issue:

"The Function "for all" have some invalid arguments

 

Im not sure about the syntax or even if Forall and iterating through each record and Patch is good approach.

 

Z_Lukowski_1-1611789636375.png

 

My fate is in your hands 🙂

 

 

Categories:
I have the same question (0)
  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at

    @Z_Lukowski, what is the Items property of your data table? Assuming it is Table1, you could try something like this: 

    ForAll(Table1, Patch( HereWeDownloadIDS, Defaults( HereWeDownloadIDS ), { IdOfDownloadedItem
    : ThisRecord.Subtitle } ))
    This assumes Subtitle is the column from which you want to copy the value. 
    Let me know if this helps. 

     

    ---
    If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

     

    Thanks!

    Hardit Bhatia

    Microsoft Business Applications MVP

    Microsoft Certified Trainer MCT

    Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Z_Lukowski ,

     

    Could you tell me:

    • What's the data type of Subtitle? Is it a Text column?

     

    If my assumption is correct, Please try the formula below:

    ForAll(DataTable2.Subtitle, Patch( HereWeDownloadIDS, Defaults( HereWeDownloadIDS ), { IdOfDownloadedItem
    : Subtitle } ))

     

    You should use Subtitle instead of DataTable2.Subtitle

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • Z_Lukowski Profile Picture
    216 on at

    hey, thx for idea,

    @v-xiaochen-msft 

    tried:

    ForAll(DataTable2.Subtitle, Patch( HereWeDownloadIDS, Defaults( HereWeDownloadIDS ), { IdOfDownloadedItem
    : Subtitle } ))

     

    Still did not work, I have also errors: Function forall has some invalid arguments, Function Patch has some invalid arguments

  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Z_Lukowski ,

     

    Could you tell me:

    What's the data type of DataTable2.Subtitle column? 

    What's the data type of IdOfDownloadedItem column? 

     

    Their data types need to be the same.

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • Z_Lukowski Profile Picture
    216 on at

    Hey Hardit,  @PowerAddict 

    So I've tried:

    ForAll(DataTable2, Patch( HereWeDownloadIDS, Defaults( HereWeDownloadIDS ), { IdOfDownloadedItem
    : ThisRecord.Subtitle } ))

    Still did not work, I have also errors: Function forall has some invalid arguments, Function Patch has some invalid arguments, Name isn't valid, the identifier isn't recognized and close to my Datatable2 info that this is not valid argument.

    I;ve used Insert->Datatable to create my table view in Power apps, it has a column ThisItem.Subtitle with 2 records filtered.

  • Z_Lukowski Profile Picture
    216 on at

    Hey @v-xiaochen-msft 

    Hey, yes, subtitle is text (in CDS tables):

    Z_Lukowski_0-1611823557342.png

    and the other is Text and primary column:

    Z_Lukowski_2-1611823699219.png

     

     

     

     

     

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Z_Lukowski ,

     

    I did a test for you:

    1\ This is my table ‘DataTable2’

    181.PNG

     

     

    2\ This is my table ‘HereWeDownloadIDS

    v-xiaochen-msft_1-1611825114853.png

     

     

    3\ Add a button control and set its onselect property to:

     

    ForAll(DataTable2S.Subtitle,Patch(HereWeDownloadIDS,Defaults(HereWeDownloadIDS),{IdOfDownloadedItem:Subtitle}))

     

    v-xiaochen-msft_2-1611825114856.png

     

     

    4\ The result is as follows:

    v-xiaochen-msft_3-1611825114856.png

     

     

    It should be noted that there can be no empty values in 'DataTable2.Subtitle', because IdOfDownloadedItem is a Primary Name Column .Its value is required.

    Otherwise the formula will report an error.

     

    Best Regards,

    Wearsky

    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • Z_Lukowski Profile Picture
    216 on at

    Hey @v-xiaochen-msft 

    The thing Ive missed based on your solution (sorry, im fairly new to the concept of power apps) is that my Datatble2 is only in Power apps (made with insert->datatable) and it was created based on Table "Badges" in CDS.

    So "Datatable2 in my example is only created in powerapps and is displaying records from "Badges" table in CDS. I've also used filter for this table based on my criteria and I want to export those filter results into final table "HereweDownloadIDs"(this one is in CDS)

    I'm Sorry if that was confusing, really appreciated your help,

    Based on this explanation is this action possible? patching filtered datatable in power apps into another table in CDS?

    Best Regards

  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Z_Lukowski , 

     

    I'm very sorry I didn't notice that you used datatable control.

    According to my test, datatable conotrol cannot currently support this formula.

    I suggest you use gallery control instead of datatable control.

     

    You could try this formula:

    ForAll(Gallery1.AllItems.Subtitle,Patch(HereWeDownloadIDS,Defaults(HereWeDownloadIDS),{IdOfDownloadedItem:Subtitle}))
    
    // Gallery1 is the name of my gallery control . 

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 320 Most Valuable Professional

#2
11manish Profile Picture

11manish 210

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard