Hihi,
I am junior for using powerapps. I have below question and hope to get help
the record is already in the database. however, I would like to edit this record and then save as a new transaction. How can i do that? Please kindly help
Hi @ArthurLin
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Hi @ArthurLin
As @yashag2255 already pointed out, you can use Patch to create copies of records, using Defaults for the BaseRecord argument of Patch.
You can also use your original record (that you want to copy) as ChangeRecord.
This might be easier than explicitly listing every control in the form, and making sure the form has all necessary controls, in order to get a full-enough copy.
If you use your original record in this way as ChangeRecord, you might have to drop the read-only columns (only for the use in Patch as ChangeRecord) which get set automatically by the Database/Dynamics/CDS (e.g. guid fields, createdby, createdon...).
Otherwise PowerApps (i.e. the CDS connector) might yield an error on your actual attempts to use Patch.
Those kinds of errors won't appear in the App Checker before actual execution.
With CDS/Dynamics, you can also replace Defaults with a record containing only a Blank() guid field to force the creation of a new record instead of overwriting an old one.
Here's a more explicit version of what I'm trying to convey:
Patch([@DataSource], { GuidField: Blank() }, originalRecord )
Good luck,
Sa.
Hi @ArthurLin ,
How do you edit existing record of your data source within your app? Using Edit form?
I assume that you use Edit form to edit an existing record in your data source within your app, based on the needs that you mentioned, I think the Patch function could achieve your needs.
I have made a test on my side, please take a try with the following workaround:
Within your Edit screen (which contains Edit form), add a Button called "Existing to New", set the OnSelect property to following:
Patch( 'YourDataSource', Defaults('YourDataSource'), EditForm1.Updates /* <-- EditForm1 represents the Edit form in your app to edit the existing record */ )
Please take a try with above solution, check if the issue is solved.
After you edit your existing record within the Edit form, click the "Existing to New" button, then it would save the modified existing record into your data source as New record.
In addition, you could also consider set the OnSelect proeprty of the "Submit" button within your Edit form to following:
Patch( /* <-- Add this formula */ 'YourDataSource', Defaults('YourDataSource'), EditForm1.Updates /* <-- EditForm1 represents the Edit form in your app to edit the existing record */ );
SubmitForm(EditForm1)
When you press the Submit button, it would update existing record in your data source, and create a new record using the modified existing record at the same time.
More details about the Patch function, please check the following article:
Best regards,
Hello @v-xida-msft
Does using Form.Updates actually work for creating proper copies?
I was under the impression that Form.Updates only produced something like a "diff" record with changes.
So, as far as I understand, this won't be creating a full copy unless you have every field in the form and actually change every field.
Please, do let me know whether my understanding is wrong.
Thank you,
Sa.
User | Count |
---|---|
142 | |
137 | |
78 | |
77 | |
73 |
User | Count |
---|---|
230 | |
177 | |
68 | |
68 | |
58 |