Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

Add rows when an item is edited in dataverse

Hello all, I want to make the code so that everytime an item is edited to add a new row with the same id in dataverse. This is the code so far. Also i'm new to this so if anyone can help me it'll be perfect. Thank you in advance.




Resident Rockstar
Resident Rockstar

Hello @yllikrs 


Is the ID that you mean the automated one generated by Dataverse or are you making a custom ID column. 


I see that your Patch code is right and would be enough to run what you need.


As for your UpdateIf, this would be the right format but not sure if it's something that you need since it just updates the status but won't create a new row.

If(Form_EditScreen.Mode = FormMode.Edit,
Status='Status (Inventories)'.Active
{Status: 'Status (Inventories).Inactive'}

If(Form_EditScreen.Mode = FormMode.Edit,
  //Add your Patch code here.
Status='Status (Inventories)'.Active
{Status: 'Status (Inventories).Inactive'});



Just in case you my answer helped you solve your problem, please mark/accept this as a SOLUTION This helps community members if they experience a similar issue in the future.   @cha_bistek    @BisTekSpace 



If you meant like this it's still not working.

The ID is automatically generated.

Hello @cha_cha,

Now the error is in the patch



Helper II
Helper II

I do not understood that if you intent to create new entry while editing a specific entry, then why you are using two if's just to check if the mode of the form is edit.

Use that condition only once and within it run your edit and new entry logic.

If you do have the specific ID, then edit the record values using that ID in the UpdateIf condition and when it's done, patch new entry whose values will be of that ID only apart from the Status (if you want to change it back to Active)

Helper II
Helper II

Also check on hovering over the patch function error and see what the error message is conveying 

No need to change it back to Active. Once it's inactive there's no need to change it back to Active. Thank you for your answer. As for the error on the patch by hovering it it says: "statecode: The specified column is generated by the server and can't be specified".

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,907)