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 / How Can I Copy Details...
Power Apps
Unanswered

How Can I Copy Details From a Form to Create a New Entry in my Datasource?

(0) ShareShare
ReportReport
Posted on by 29

In my app (which is connected to a SharePoint data source), users have the ability to fill out a form which creates a new entry in the SharePoint table. My app also has a gallery where users can see/edit forms they have already filled out. When users click into a previously filled out form, I have created a button that will create a copy of that form, and it should create a new entry in the table. I have roughly accomplished this, but could use some additional input.

 

Firstly, the table in my SharePoint data source has a column for ID & TestRequestNumber.

 

The ID field is automatically generated with each new entry, and the TestRequestNumber needs to be generated based on the ID+20000. The query I'm using is creating new entries in the table, but it isn't updating the TestRequestNumber how I want it to.

Screenshot 2024-01-31 090221.png

This is the complete query I'm using: 

 

Set(
 TestRequestCopiedID,
 Patch(
 'MyTable',
 varRequestDbData,
 myNewForm_2.Updates
 )
);
Patch(
 'MyTable',
 First(
 Filter(
 'MyTable',
 ID = TestRequestCopiedID.ID
 )
 ),
 {
 TestRequestNumber: TestRequestCopiedID.ID + 20000
 }
);
Patch(
 'MyTable',
 Defaults('MyTable'),
 {
 TestRequestNumber: TestRequestCopiedID.ID + 20000,
 Title: DataCardValue205_1.Text & " - Copy",
 'Department Number': cmbDept.Selected.DeptValue, 
 'Test Type': DataCardValue33.Selected, 
 ProjectNumber: cmbProjNum.Selected.projectValue, 
 'Project Phase': DataCardValue127.Selected, 
 'Business Unit': DataCardValue292.Selected.Value,
 'Test Group': DataCardValue333.Selected, 
 Requestor: DataCardValue334.Text,
 'Approving Manager Name': ComboBox5.Selected.DisplayName,
 'Test Advisor': ComboBox7.Selected.Title,
 Reason: DataCardValue220_1.HtmlText,
 Deliverables: DataCardValue221_1.HtmlText,
 Background: DataCardValue222_1.HtmlText,
 'Engineering Asset': DataCardValue64.SelectedItems,
 Configurations: DataCardValue225_1.HtmlText,
 Standards: DataCardValue16.SelectedItems,
 'Post Test Information': DataCardValue224_1.HtmlText,
 'Acceptance Criteria': DataCardValue226_1.HtmlText,
 'Test Procedure': DataCardValue227_1.HtmlText
 }
);
Set (CopyTRNum, TestRequestCopiedID.ID + 20000);
Notify("New Test Request ID: TR" & CopyTRNum & ". You can close the form in 5 seconds...");
Set (startTimer, true);

 

 

Let's break it down:

 

Set(
 TestRequestCopiedID,
 Patch(
 'MyTable',
 varRequestDbData,
 myNewForm_2.Updates
 )
);
Patch(
 'MyTable',
 First(
 Filter(
 'MyTable',
 ID = TestRequestCopiedID.ID
 )
 ),
 {
 TestRequestNumber: TestRequestCopiedID.ID + 20000
 }
);

 

 

The above portion of my query is pulled from the section of my app where users are filling out details of a new form. The only difference between the two queries would be the update being patched in the first patch function.

 

Patch(
 'MyTable',
 Defaults('MyTable'),
 {
 TestRequestNumber: TestRequestCopiedID.ID + 20000,
 Title: DataCardValue205_1.Text & " - Copy",
 'Department Number': cmbDept.Selected.DeptValue, 
 'Test Type': DataCardValue33.Selected, 
 ProjectNumber: cmbProjNum.Selected.projectValue, 
 'Project Phase': DataCardValue127.Selected, 
 'Business Unit': DataCardValue292.Selected.Value,
 'Test Group': DataCardValue333.Selected, 
 Requestor: DataCardValue334.Text,
 'Approving Manager Name': ComboBox5.Selected.DisplayName,
 'Test Advisor': ComboBox7.Selected.Title,
 Reason: DataCardValue220_1.HtmlText,
 Deliverables: DataCardValue221_1.HtmlText,
 Background: DataCardValue222_1.HtmlText,
 'Engineering Asset': DataCardValue64.SelectedItems,
 Configurations: DataCardValue225_1.HtmlText,
 Standards: DataCardValue16.SelectedItems,
 'Post Test Information': DataCardValue224_1.HtmlText,
 'Acceptance Criteria': DataCardValue226_1.HtmlText,
 'Test Procedure': DataCardValue227_1.HtmlText
 }
);

This portion of my query is functioning as intended. New entries in my table contain the data from the form being copied.

 

That being said, when I go to actually create a copy of the form, the TestRequestNumber field isn't generating based on the ID. For some reason it's generating based on the ID of the form being copied. This leads newly copied entries to my table looking like this:

Screenshot 2024-01-31 090221.png

You can see that each copied entry in the table have new IDs, but the TestRequestNumber is still being updated based on the ID of the form, not the newly created ID. For these entries, I want the TestRequestNumber to be 20848 & 20847 respectively.

 

Does anyone have any advice on how I can solve my problem with TestRequestNumber of copied forms reflecting the original ID of the form?

Categories:

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 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard