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 / Patch creating new rec...
Power Apps
Unanswered

Patch creating new record instead of updating recode

(0) ShareShare
ReportReport
Posted on by 10

 

 

Patch(
colDridData,
ThisItem,
{
No_of_Pax: No_of_Pax_DropDown.Selected,
Country: Country_DropDown.Selected,
DMC: DMC_DropDown.Selected,
TO_Agent: TO_Agent_DropDown.Selected,
Hotel: Hotel_DropDown.Selected,
Remarks: Remarks_LBL.Text
}
);

 

 

CodeCodeOutoutOutout

Categories:
I have the same question (0)
  • v-hanytian-msft Profile Picture
    Microsoft Employee on at

    Hi @tharakadilshan ,

     

    Please try this:

    Patch(
    colDridData,
    Defaults(colDridData),
    {
    No_of_Pax: No_of_Pax_DropDown.Selected,
    Country: Country_DropDown.Selected,
    DMC: DMC_DropDown.Selected,
    TO_Agent: TO_Agent_DropDown.Selected,
    Hotel: Hotel_DropDown.Selected,
    Remarks: Remarks_LBL.Text
    }
    );

     

    Reference Document:

    vhanytianmsft_0-1692766717249.png

    Patch function in Power Apps (contains video) - Power Platform | Microsoft Learn

     


    Hope this will help you,

    Best Regards,
    Tina

  • tharakadilshan Profile Picture
    10 on at

    Hi,

     

    This is also not working 😣

     

    Thank you

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

    Hi @tharakadilshan ,

     

    Is there any Error Message in the canvas app?

    Also Do you want to add a new recoed into colDridData or another DataSource?

     

    Please try to run this function and check it as below to see if it worked or not.

    vhanytianmsft_0-1692770356633.png


    Hope this will help you,

    Best Regards,
    Tina

  • Talha_Dar Profile Picture
    870 Super User 2024 Season 1 on at

    Hi @tharakadilshan,

     

    Try using the following and see if it helps.

     

    Patch(
    colDridData,
    Defaults(colDridData),
    {
    No_of_Pax: No_of_Pax_DropDown.Selected.Value,
    Country: Country_DropDown.Selected.Value,
    DMC: DMC_DropDown.Selected.Value,
    TO_Agent: TO_Agent_DropDown.Selected.Value,
    Hotel: Hotel_DropDown.Selected.Value,
    Remarks: Remarks_LBL.Text
    }
    );

     

    If the above code shows error try using the following.

     

    Patch(
    colDridData,
    Defaults(colDridData),
    {
    No_of_Pax: No_of_Pax_DropDown.Selected.No_of_Pax,
    Country: Country_DropDown.Selected.Country,
    DMC: DMC_DropDown.Selected.DMC,
    TO_Agent: TO_Agent_DropDown.Selected.TO_Agent,
    Hotel: Hotel_DropDown.Selected.Hotel,
    Remarks: Remarks_LBL.Text
    }
    );

     

    If you found my answer helpful, please consider giving it a thumbs-up or a like. Your feedback is greatly appreciated!

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • tharakadilshan Profile Picture
    10 on at

    Hi Tina,

     

    I can add a new recode to colDridData using this patch function.

    Collect(
     colDridData,
     Patch(
     varNewRecord,
     {ID: varNumber}
     )
     )

    But when I tried to select an item from the combo box it update the current recode and also create a new recode with the same data. for that, I use this function in the "Onchange" activity in every combo box.  

    Patch(
     colDridData,
     ThisItem,
     {
     No_of_Pax: No_of_Pax_DropDown.Selected,
     Country:Country_DropDown.Selected,
     DMC:DMC_DropDown.Selected,
     TO_Agent:TO_Agent_DropDown.Selected,
     Hotel:Hotel_DropDown.Selected,
     Remarks:Remarks_LBL.Text
     }
    
    );

     

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

    Hi @tharakadilshan ,

     

    Please try as @Talha_Dar  Write.

    If the Items of the DropDown is the one singel Table or just a Colimn.

    Try this:

    Patch(
    colDridData,
    Defaults(colDridData),
    {
    No_of_Pax: No_of_Pax_DropDown.Selected.Value,
    Country: Country_DropDown.Selected.Value,
    DMC: DMC_DropDown.Selected.Value,
    TO_Agent: TO_Agent_DropDown.Selected.Value,
    Hotel: Hotel_DropDown.Selected.Value,
    Remarks: Remarks_LBL.Text
    }
    );

     If the Items of the  DropDown is a Table.

    Try this:

    Patch(
    colDridData,
    Defaults(colDridData),
    {
    No_of_Pax: No_of_Pax_DropDown.Selected.No_of_Pax,
    Country: Country_DropDown.Selected.Country,
    DMC: DMC_DropDown.Selected.DMC,
    TO_Agent: TO_Agent_DropDown.Selected.TO_Agent,
    Hotel: Hotel_DropDown.Selected.Hotel,
    Remarks: Remarks_LBL.Text
    }
    );


    Hope this will help you,

    Best Regards,
    Tina

  • tharakadilshan Profile Picture
    10 on at

    Hi, @v-hanytian-msft @Talha_Dar 

     

    both codes are showing errors, 

    Tks

     

    3.png4.png

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

    Hi @tharakadilshan ,

     

    May I ask waht type of Column which are shows Error?

    If it is the Choice, please try this:

    Patch(
    colDridData,
    Defaults(colDridData),
    {
    No_of_Pax: LookUp(Choice([@Table].Column),No_of_Pax_DropDown.Selected.Value = Value)
    })
    


    Hope this will help you,

    Best Regards,
    Tina

  • tharakadilshan Profile Picture
    10 on at

    Hi @v-hanytian-msft 

     

    All Combo box & Text column has the same error

     

    Thank you

  • Talha_Dar Profile Picture
    870 Super User 2024 Season 1 on at

    Hi @tharakadilshan,

     

    Can you please specify the column types of these columns.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard