web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patching two things at...
Power Apps
Answered

Patching two things at once?

(1) ShareShare
ReportReport
Posted on by 28
Here is the basics of my app: I have an app where users can complete forms that are tied to a SP list. The data in the list is then used to generate a word document/PDF based on a template. 
Users are able to save versions as drafts, as well as make updates to existing generated versions. I am going to do my best to describe what it looks like, because I am unable to take screenshots of most of the content. 
 
I used Reza Dorrani's Save as Draft in Power Apps form to create the current process. It works great but I am having to do a lot of manual work to maintain the list since users are now going in and making updates to their originally created documents. 
 
Here is where I am stuck,  User clicks on document 31 in a gallery. A container pops up asking if this is still active or inactive. if active, it goes to another screen where the record info for document 31 is populated into forms. There the user can update or make changes.  [I am currently using Gallery.select but have looked into changing that]
 
Basically I would like to have two parallel actions that take place. One is that the Document 31 record info is loaded into forms to be edited under a new document ID. And that document 31 is marked as being archive data and is no longer editable. 
 
I am getting stuck in how to do both of those actions at almost the same time. I had tried to follow these directions (https://www.youtube.com/watch?v=fu8OEbD7YqQ) but it would not pull in the existing data which is needed.  
 
I feel like I am missing something obvious, but have no idea what that could be. Please let me know if there is anything I missed that might help. Thanks!
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,969 Moderator on at
     
    There are a couple of variables here but let me explain what you could do. In fairness I do not go read other peoples blogs or watch videos from others, I am looking for stuff from the user to explain what they did.
     
    1. On Screen A, let's assume you have a button to navigate or if you have something in the Gallery that you click to move.
    Either way there is a OnSelect that will be triggered
     
    in the OnSelect
    First Do a Patch like this
    // Add your new record
    Fill in all your fields. making sure to copy what you need from the .Selected that you need, 
    and populated the others with whatever you need.
    
    Set(Result, Patch(MyDataSource, Defaults(MyDataSource)
           {
               AddFieldNamne: Gallery.Selected.FIeldValue
           }
          )
    );
    
    // Update your existing record
    
    Patch(MyDataSource, Gallery.Selected, { MyStatusField: WhateverValueYouWantedToSetit to });
    
    Refresh(MyDataSource); //this just to make sure its got the new record in it
     
    Now technically we should wrap that in an Error check so that if it fails we do NOT move to the next step but let's just get you moving forward and then add that
     
    In your Navigate I want you to change it to this
     
    Navigate(Screen2, Transition.None (or whatever you want), {  _NewRecordId: Set.ID });
    That will pass the ID of the new SharePoint Item you created.
     
    In your screen 2, change the Item property of the form to be
     
    LookUp(MyDataSource, ID = _NewRecordID) 
     
    So that it pulls up your new record that you just created.
    And now they can update it and do whatever you want.
  • rutledgeam Profile Picture
    28 on at
    Thank you for your response- I think I got confused along the way. I created a test list to work with and took screenshots below. The list is pretty basic, the document status and program status columns are choice fields. 
     
    So using the data below I would like for all of the record info for the ID 1 (Test Project) to be on a new line with a new ID, and then document status for ID 1 to be changed to archive. 
     
    I tried to follow your formula below but I got stuck at the _NewRecordID part- it was giving me error messages. 
     
     
    Thank you for your help- I feel like I just can't figure out what I need to do to make this work! 
  • Hasrie Profile Picture
    202 on at
    Hi try to make it simple. I have tried playing with patch onto multiple SPList, one with RAW data, edited data such as workers merits points (annually) and backup data as you like, machine up and downtime for maintenance to update their dashboard, up to 30 checklist type for forklift such vehicle. Refer to the attach photo so you can actually understand the step before proceeding with canvas app where it goes to multiple lists first, then figure out how to edit specific list without having all crowded data in the same page
    t2.png
    t4.png
    t3.png
  • ronaldwalcott Profile Picture
    3,862 Moderator on at
    You should probably not archive the data before you have initialized the data in the new form.
    Do you want to go to a new form and the data is automatically populated in the fields then you generate or enter a new document ID; or do you want to duplicate the data with a new document ID and then go to the form which would be in edit mode to edit the data?
    Either way you should not archive the previous record without verifying in some way that the new record is actually created. In the first option that would be a patch when the data is saved.
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,969 Moderator on at
     
    Apologies, I goofed in typing, change it to Result.Id as that is the variable holding the new id
     
    Don't forget the ) at the end of the Navigate(might be there I just couldn't see)
     
     
     
  • rutledgeam Profile Picture
    28 on at
    Thank you all for your help! I feel like I am getting closer to solve it, 
     
    To answer a question below: 
    Do you want to go to a new form and the data is automatically populated in the fields then you generate or enter a new document ID; or do you want to duplicate the data with a new document ID and then go to the form which would be in edit mode to edit the data?
     
    The last one! 
     
    The data needs to be in a form so that the user can edit what already exists and not have to start all over again. 
  • Michael E. Gernaey Profile Picture
    53,969 Moderator on at
     
    Which is how I wrote it for you since thats what you asked for. 
  • rutledgeam Profile Picture
    28 on at
    Thank you @Michael E. Gernaey for all your help! I ended up with this- for some reason it did not like the second patch the way it weas written (gallery.select) so I had to modify, 
    I need to work on the first patch. The SP list unfortunately has about 100 columns so to add each line column is going to take forever. My current patch formula uses forms and updates so I might try and rework my screen so that all of the data is on there some how. 
     
    Thank you again for all your help- I feel like I have been banging my head on my desk trying to figure this out! 
  • Michael E. Gernaey Profile Picture
    53,969 Moderator on at
     
    I love your thinking. If you need more help on re-working feel free to open another question then just DM me or @Michael E. Gernaey and I will respond.
     
    Apologies, if I may have just typed like Gallery.Selected etc I tend to sometimes forget to tell people to change the names to their Controls apologies for that.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard