Power Apps copy Data Card Value to another field

Loading

Requirement: Power Apps copy Data card Value to another field, When the user clicks the button after filling out the form, the information will be copied from the Billing Details form to the Shipping Details form. Furthermore, once copied, clicking another button will submit data to the appropriate SharePoint list.

Create two SharePoint lists  Product Billing and Product Shipping

Product Billing:

Power Apps copy value to another field

Product Shipping:

Copy Power Apps value to another field

Now to fulfil the requirement, create two Power Apps edit forms (i.e., Product Billing Details and Product Shipping Address) using the above SharePoint lists (Product Billing and Product Shipping).

To create the edit forms within the Power Apps, the following steps are:

  • In the Power Apps, build a blank canvas app.
  • It will redirect to the Power Apps screen where can add and build edit forms.
  • Add the above-mentioned SharePoint lists to the Power Apps.
  • Let’s add an edit form and connect it to the one SharePoint list Or select one edit form and insert the SharePoint list name on the edit form’s DataSource property.
DataSource = 'Product Billing'

Where ‘Product Billing’ is the name of the SharePoint list. Once the data source is connected to the Power Apps edit form, it will retrieve all the fields from the SharePoint DataSource.

Connect SharePoint Data Source to Power Apps edit form

Similarly, add another Power Apps edit form to the above screen and connect it with another SharePoint list i.e., Product Shipping.

DataSource = 'Product Shipping'

Copy PowerApps value to another field

  • According to the specification, Copy the field values from the Product Billing Details form to the Product Shipping Details.
  • Add a Power Apps button control to the app and give a text to the button on the button’s Text property.
Text = "Click here to copy Billing to Shipping"

Power Apps copy field value to another field

Insert the below expression on the button’s OnSelect property to create an update context variable.

OnSelect = UpdateContext({ButtonPress:true})

Where ButtonPress is the name of the Update Context variable and value is true.

How to copy PowerApps value to another field

  • Next, on the second edit form (Product Shipping Details), unlock all the Data Cards to change their properties.
  • Select the Product Title’s TextInput field and insert the below expression on the TextInput’s Default property.
Default = If(ButtonPress=true, DataCardValue1.Text, Parent.Default)

Where, DataCardValue1 refers the name of the Product Title‘s field value from the first edit form (Product Billing Details).

How to copy PowerApps field value to another field

Similarly, set the default properties of the other fields(on the Product Shipping Details) by using the Product Billing Details form’s fields.

Default = If(ButtonPress=true,DataCardValue2.Text,Parent.Default)
//On Shipping Street's TextInput
Default = If(ButtonPress=true,DataCardValue3.Text,Parent.Default)
//On Shipping City's TextInput
Default = If(ButtonPress=true,DataCardValue4.Text,Parent.Default)
//On Shipping State's TextInput
Default = If(ButtonPress=true,DataCardValue5.Text,Parent.Default)
//On Shipping Zip's TextInput
Default = If(ButtonPress=true,DataCardValue6.Text,Parent.Default)
//On Shipping Country's TextInput
DefaultDate = If(ButtonPress=true,DataCardValue7.SelectedDate,Parent.Default)
// On Shipping Date's DatePicker

Where, DataCardValue1DataCardValue2DataCardValue3DataCardValue4,DataCardValue5, DataCardValue6 and DataCardValue7 are the name of the field values of the Product Billing Details form.

Copy Data Card fields to another in Power Apps

To submit the copied data to the data source, add a Save icon to the app and insert the below expression on the Save icon’s OnSelect property

OnSelect = SubmitForm(ProductShippingForm);SubmitForm(ProductBillingForm);If(ButtonPress=true,Refresh('ProductShipping'),false);UpdateContext({ButtonPress:false});NewForm(ProductShippingForm);ResetForm(ProductBillingForm); ResetForm(ProductShippingForm)

Where ProductBillingForm and ProductShippingForm are the name of the edit forms respectively.

Copy Data Card fields to another in PowerApps

Now Save and publish the app. Open the app in preview mode and fill out all the fields on the Product Billing Details form. Once we click on the button, all the fields values will be copied and reflected those copied data on the another form (Product Shipping Details).

Copy DataCard fields to another in Power Apps

Then, click on the Save icon to save those data to the respective SharePoint lists as shown below:

Power Apps copy Data Card value to another field

Leave a Reply

Your email address will not be published. Required fields are marked *