cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
yllikrs
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.

yllikrs_0-1669201843280.png

yllikrs_1-1669201925682.png

 

6 REPLIES 6
cha_cha
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,
UpdateIf(Inventories,
Status='Status (Inventories)'.Active
{Status: 'Status (Inventories).Inactive'}
));

If(Form_EditScreen.Mode = FormMode.Edit,
  //Add your Patch code here.
);
UpdateIf(Inventories,
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.

 
bistek.space   @cha_bistek    @BisTekSpace 

yllikrs_0-1669205095106.png

 

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

yllikrs_3-1669205351462.png

 

JatinSaini
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)

JatinSaini
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

Announcements
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)