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.
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:
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?

Report
All responses (
Answers (