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 to multiple l...
Power Apps
Answered

Patching to multiple lists not working (Randomly)

(2) ShareShare
ReportReport
Posted on by 14
Hi everyone, My data is stored across 5 sharepoint lists. The first SP list is the user details. The ID in this list becomes the Parent ID column in the other 4 SP lists where additioanl data is stored. I cannot add all data to one large SP list as there are too many columns.

The save process does the following:

Submits Details Form 1, captures the ID of the item just submitted in a variable
Submits 4 other forms to create the line items in each of the other lists
Patches Additional details form 1 to a second SP list where captured ID above matches the Parent ID column in this SP list
Patches Additional details form 2 to a third SP list where captured ID above matches the Parent ID column in this list SP list
Patches Additional details form 3 to a fourth SP list where captured ID above matches the Parent ID column in this list SP list
Patches Additional details form 4 to a Fifth SP list where captured ID above matches the Parent ID column in this list SP list

My challenge is this randomly submits updates to items successfully (most of the time) and then randomly doesn't update changes to the additional lists on other occasions. 

My users are getting frustrated after completing/editing all the forms only to have their entries not submit. Anyone experienced this and know why it happens? 

Initial Save Button does this:
 
SubmitForm('Details Form 1')

On Success of details form then does this:
 
Set(VarPatchID, 'Details Form 1'.LastSubmit.ID);
 
SubmitForm('Set Up For Success 1 of 1 Form');
SubmitForm('Project Management Delivery 1 of 2 Form');
SubmitForm('Project Management Delivery 2 of 2 Form');
SubmitForm('People and Behaviour 1 of 1 Form');
 
Patch('PM Capability Set Up For Success Scores 1 of 1',LookUp('PM Capability Set Up For Success Scores 1 of 1','Title'= Text(VarPatchID)), //Last submitted record or edited item
    'Assessment SUFS-01'.Updates,
    'Assessment SUFS-02'.Updates,
    'Assessment SUFS-03'.Updates,
    'Assessment SUFS-04'.Updates,
    'Assessment SUFS-05'.Updates,{'Title':VarPatchID});
 
Patch('PM Capability Project Management Delivery Scores 1 of 2',LookUp('PM Capability Project Management Delivery Scores 1 of 2','Title'= Text(VarPatchID)), //Last submitted record
    'Assessment PMD-01'.Updates,
    'Assessment PMD-02'.Updates,
    'Assessment PMD-03'.Updates,
    'Assessment PMD-04'.Updates,
    'Assessment PMD-05'.Updates,
    'Assessment PMD-06'.Updates,
    {'Title':VarPatchID});
   
Patch('PM Capability Project Management Delivery Scores 2 of 2',LookUp('PM Capability Project Management Delivery Scores 2 of 2','Title'= Text(VarPatchID)), //Last submitted record
    'Assessment PMD-07'.Updates,
    'Assessment PMD-08'.Updates,
    'Assessment PMD-09'.Updates,
    'Assessment PMD-10'.Updates,
    'Assessment PMD-11'.Updates,
    'Assessment PMD-12'.Updates,
    {'Title':VarPatchID});
 
Patch('PM Capability People and Behaviour Scores 1 of 1',LookUp('PM Capability People and Behaviour Scores 1 of 1','Title'= Text(VarPatchID)), //Last submitted record or edited item
    'Assessment PAB-01'.Updates,
    'Assessment PAB-02'.Updates,
    'Assessment PAB-03'.Updates,
    'Assessment PAB-04'.Updates,
    'Assessment PAB-05'.Updates,
    {'Title':VarPatchID});
 
Navigate(HomeScreen);

 

 
Categories:
I have the same question (0)
  • Verified answer
    Vish WR Profile Picture
    3,748 on at
     

    Power Apps is submitting multiple forms and running patches at the same time, without properly waiting for the first record to be fully created. Because of that, the ID may not be available yet, or the SharePoint lookup may return the wrong record, so the updates fail randomly.

    First, submit the main “Details Form 1” and only after it successfully saves, capture the generated ID. Once that ID is confirmed, use it as the Parent ID for everything else. Then submit the other forms and update the related SharePoint lists using that Parent ID, making sure each list either updates an existing record or creates one if it doesn’t exist.

    In short, everything should depend on the first saved record finishing properly. Once that ID is locked in, all other updates should reliably reference it instead of trying to run in parallel or relying on LookUp with Title.

     

    Vishnu WR
     
    Please  Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like 


     
  • Verified answer
    Haque Profile Picture
    3,653 on at
    Hi @SR-27041218-0,
     
    Let's analyze the rootcause first:
     
     
    1. The SubmitForm() function is asynchronous. Calling multiple SubmitForm() functions sequentially without waiting for each to finish can cause race conditions or incomplete data. What can be done? Let's wait for each form submission to complete before proceeding.
    2. Let's wait for success opertations - please chain the submissions so that the next form or Patch only runs after the previous one succeeds. What can be done? Let's use the OnSuccess event of each child form to trigger the next submission or Patch.
    3. It seems like your Patch calls use LookUp() to find records by Title = VarPatchID. If the record is not yet created or the lookup fails, the Patch will silently fail. What to do? Let's ensure/confirm the record exists before patching.
    4. It is not cleary you have handled error or not! - what to do?  Use IfError() or check form errors to detect and handle failures gracefully.
     
     
    Sample approach you can follow for chaining:
     
     
    // On Save button, we can submit the form
    SubmitForm(DetailsForm1);
    
    // On DetailsForm1.OnSuccess:
    Set(VarPatchID, DetailsForm1.LastSubmit.ID);
    SubmitForm(SetUpForSuccessForm);
    
    // On SetUpForSuccessForm.OnSuccess:
    SubmitForm(ProjectManagementDelivery1Form);
    
    // On ProjectManagementDelivery1Form.OnSuccess:
    SubmitForm(ProjectManagementDelivery2Form);
    
    // On ProjectManagementDelivery2Form.OnSuccess:
    SubmitForm(PeopleAndBehaviourForm);
    
    // On PeopleAndBehaviourForm.OnSuccess:
    Patch(...); // Your Patch calls here
    Navigate(HomeScreen);
    
     
     
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
     
  • Verified answer
    Haque Profile Picture
    3,653 on at
     
    For safer patch update - you can handle error with notification like this:
     
    
    IfError(
        Patch('PM Capability Set Up For Success Scores 1 of 1',
            LookUp('PM Capability Set Up For Success Scores 1 of 1', Title = Text(VarParentID)),
            {
                'Assessment SUFS-01': 'Assessment SUFS-01'.Updates,
                'Assessment SUFS-02': 'Assessment SUFS-02'.Updates,
                'Assessment SUFS-03': 'Assessment SUFS-03'.Updates,
                'Assessment SUFS-04': 'Assessment SUFS-04'.Updates,
                'Assessment SUFS-05': 'Assessment SUFS-05'.Updates,
                Title: VarParentID
            }
        ),
        Notify("Failed to update Set Up For Success Scores", NotificationType.Error),
        // On success, continue to next Patch
        IfError(
            Patch('PM Capability Project Management Delivery Scores 1 of 2',
                LookUp('PM Capability Project Management Delivery Scores 1 of 2', Title = Text(VarParentID)),
                {
                    'Assessment PMD-01': 'Assessment PMD-01'.Updates,
                    'Assessment PMD-02': 'Assessment PMD-02'.Updates,
                    'Assessment PMD-03': 'Assessment PMD-03'.Updates,
                    'Assessment PMD-04': 'Assessment PMD-04'.Updates,
                    'Assessment PMD-05': 'Assessment PMD-05'.Updates,
                    'Assessment PMD-06': 'Assessment PMD-06'.Updates,
                    Title: VarParentID
                }
            ),
            Notify("Failed to update Project Management Delivery Scores 1 of 2", NotificationType.Error),
            // Continue chaining similarly for other Patch calls...
            Patch('PM Capability Project Management Delivery Scores 2 of 2',
                LookUp('PM Capability Project Management Delivery Scores 2 of 2', Title = Text(VarParentID)),
                {
                    'Assessment PMD-07': 'Assessment PMD-07'.Updates,
                    'Assessment PMD-08': 'Assessment PMD-08'.Updates,
                    'Assessment PMD-09': 'Assessment PMD-09'.Updates,
                    'Assessment PMD-10': 'Assessment PMD-10'.Updates,
                    'Assessment PMD-11': 'Assessment PMD-11'.Updates,
                    'Assessment PMD-12': 'Assessment PMD-12'.Updates,
                    Title: VarParentID
                }
            );
            Patch('PM Capability People and Behaviour Scores 1 of 1',
                LookUp('PM Capability People and Behaviour Scores 1 of 1', Title = Text(VarParentID)),
                {
                    'Assessment PAB-01': 'Assessment PAB-01'.Updates,
                    'Assessment PAB-02': 'Assessment PAB-02'.Updates,
                    'Assessment PAB-03': 'Assessment PAB-03'.Updates,
                    'Assessment PAB-04': 'Assessment PAB-04'.Updates,
                    'Assessment PAB-05': 'Assessment PAB-05'.Updates,
                    Title: VarParentID
                }
            );
            Navigate(HomeScreen)
        )
    )
    
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • SR-27041218-0 Profile Picture
    14 on at
    Thanks @Haque,

    Taking your suggestion of splitting the submits to after each form was successful seem to have worked. Slows the whole process down. 

    I also realised that the app only needed to submit the other 4 forms when it was a new item.  When new, it follows your set up above to stop conflicts in forms and patches, when editing it just runs the patch and doesnt submit the forms.

    Thanks for your help on this one!
     
  • Haque Profile Picture
    3,653 on at
     
    Feeling happy - it worked. 
  • Vish WR Profile Picture
    3,748 on at
     
    glad it worked for you .
     
     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard