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 / Create a new master re...
Power Apps
Unanswered

Create a new master record and detail record from button click

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

The following code below will create a Master record.

What I need:

I need to create a "detail" record using the ID created in the patch statement below.(from master)  
The detail table is called "t_pricing_escalation_detail"

The foreign field is  "RBP_MASTER_ID"  

 

 

Set(MyRecord,
Patch(t_pricing_escalation_master,Defaults(t_pricing_escalation_master),
{
ESCALATION_CREATED_BY: User().FullName,
QS_RACFID: txt_QS_RACFID.Text
}
)
)

 

Thanks

Dave

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    You're storing the patch results in your MyRecord variable. This will have all of the information you need for you other patch. 

    Patch(t_pricing_escalation_detail, Defaults(t_pricing_escalation_detail),
     {RBP_MASTER_ID: MyRecord.ID}
    )

    Will give you a new record with the master record ID in the RBP_MASTER_ID column.

     

    I hope this is helpful for you. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    randy, getting this error ?

    Both fields are INT in sql server.

    error patch with id.png

    Set(MyRecord,
    Patch('[dbo].[t_redbook_pricing_escalation_master]',Defaults('[dbo].[t_redbook_pricing_escalation_master]'),
    {

    ESCALATION_CREATED_BY: User().FullName,
    QS_RACFID: txt_QS_RACFID.Text


    }
    )
    )
    ;
    Patch('[dbo].[t_redbook_pricing_escalation_detail]', Defaults('[dbo].[t_redbook_pricing_escalation_detail]'),
    {
    RBP_MASTER_ID: MyRecord.PRICING_ESCALATION_ID

    }
    )

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    If you're getting a "found type error", then something else is at play.  

    I would take the formula in error out for the moment and then look at the variable you are setting (MyRecord) to see what is in that column PRICING_ESCALATION_ID

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    This is a primary key  AUTONUMBER field.   PRICING_ESCALATION_ID

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard