To simplify data entry, we can add a feature that enables a user to save an existing record as a new record.
This post walks through how add a button to an edit screen that copies the existing record as a new record. To help identify the record, the new record will include the suffx " Copy" in a prominent field.
Pre-requiste stepsAs a starting point, we'll build an auto generated app that's based on a SharePoint property list. The schema of this list looks like this:
Using pattern that I described in the link beneath, we'll set a variable that stores the current record on the OnSelect property of the gallery control on the browse screen.
Next, we modify the Item property of the display and edit screens to reference the varCurrentRecord variable.
Adding a 'Save as copy' button to the edit screen
On the edit screen, we now add a button or icon to save the existing record as a new record. We set the formula in the OnSelect property to the following:
This sets a variable called locCopy to indicate that we want to make a copy of the record.
We should initialise this variable to false on the OnVisible property of the screen:
Next, we modify the Item property of edit form like so:
This formula tests the value of the locMakeCopy variable. If this is true, the call to patch blanks out the primary key, ID value. This is handy tip that I picked up from Randy Hayes. When the SubmitForm function encounters an empty primary key value, it adds the record as a new record, even if the FormMode of the form is set to Edit, rather than New.
If the locMakeCopy variable is false, we set the Item property to varCurrentRecord to support the ability to update the existing record.
Finally, we can optionally modify the update property of the Address1 card like so:
DataCardValue9.Text & " (copy)",
This configures the card to append the word " (copy)" to the value that it saves to the SharePoint/data source when the value fo the locMakeCopy variable is true. In this example, DataCardValue9 refers to the text input control within the Address1 card.
To simplify data entry, we can add a feature that creates a copy of an existing record. This post described a technique that we can apply to an edit screen with a form. The key step is to blank the primary key value. This configures the SubmitForm function to add the record as a new record, rather than update the existing record.