top of page
Search

In this post let us see, how to show a successfully submitted record's data back on to the form, as a confirmation.


Take two forms

  • frmStudentGenInfo

  • frmStudentContactInfo

on SUBMIT button use the below expression

ClearCollect(colSubmittedData,Patch(Students,Defaults(Students), frmStudentGenInfo.Updates,frmStudentContactInfo.Updates));Navigate('Success Screen')

Now: on "Success Screen" - take a lable and use below expression to show the ID created in Common Data Service on submit

"Submission was successful." & " Registration ID: " & First(colSubmittedData).'Student ID'
ree
ree

 
 
 

  • Make sure the "Default Mode" property of a FORM control is set to "New" in case its used to create a new record

  • Make user the Form control is reset after each new record creation/submission. Otherwise due to old data cache the FORM can't be visible on the screen

  • Performance of the below expression is slow because every time the Defaults() function is invoked, there is a call to the server where MyTable is stored.  The above expression would then make at least two calls, one for the Defaults() and one for the Patch().

Patch(
    Student,
    Defaults(Student),
    {studentName: "Power Assist", email: "powerassist@gmail.com"})
  • The only columns that are really needed are the ones that participate in the primary key.  Normally this is just an id column.  So actually in a lot of cases, something like this will work for creating a new record:

Patch(Student,
    {ID: Blank()},
    {studentName: "Power Assist", email: "powerassist@gmail.com"})
 
 
 

We can create records in CDS (for that matter any Data Source) from canvas app Using a PATCH function


Now let us se how can we create a record Using a PATCH function


there are two ways that we can make use of PATCH function to create a record.

  1. Multi Form

  2. using controls to create a record

Multi Form

suppose if we want to show some data as sectional information (to let the user fill up the form in sections) we can use this Multi Forms.


scenario: if we have a data source called "Students", which has around 10 fields to create a single student entry. We wanted to show up a form (frmStudentGenInfo) as one section called "General Information" and another form (frmStudentContactInfo) as a section called "Contact Information"


Now to create a record on a button click use this below snippet

PATCH(Students, frmStudentGenInfo.Updates,frmStudentContactInfo.Updates)

using OOB controls to create a record


Scenario: if we planned to create our own UI (since we cannot customize a FORM control layout) with OOB controls to create a record in the back-end we can go with this PATCH control

Patch(
    Students,
    Defaults(Students),
    {studentName: "Power Assist", email: powerassit@gmail.com}
    )
ree
ree
ree

Refer this to check out how to create a record using a FORM Control

 
 
 
bottom of page