Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

How to submit a new form and edit form together?

Posted on by 70
I have two forms (one is a new form and another is an edit form) and I want to submit the content of both forms together.
When I am using: Patch('Tracker',Defaults('Tracker'),Form1.Updates,Form2.Updates);Navigate('Success screen'), it is creating a new line item in the SharePoint. But I want the information to go in the same line item (basically update the line item in Sharepoint with new information).
 
How can I resolve this?
Categories:
  • Suggested answer
    Ammar Zaied Profile Picture
    Ammar Zaied 97 on at
    How to submit a new form and edit form together?
    Hi,
    Use a Variable to Store the Item ID:
    // When navigating to the edit form
    Set(currentItemID, YourItemID);
    Navigate(EditScreen);
    
    Patch Function Adjustment
     
    If(
        Form1.Valid && Form2.Valid, // Check if both forms are valid
        Patch(
            Tracker,
            LookUp(Tracker, ID = currentItemID), // Find the existing item by ID
            Form1.Updates,
            Form2.Updates
        );
        Navigate(SuccessScreen) // Navigate to the success screen only if Patch is successful
    )
    
     
    Handling Errors
     
    If(
        Form1.Valid && Form2.Valid,
        If(
            IsBlank(Patch(
                Tracker,
                LookUp(Tracker, ID = currentItemID),
                Form1.Updates,
                Form2.Updates
            )),
            Notify("Error updating item", NotificationType.Error),
            Navigate(SuccessScreen)
        ),
        Notify("Form validation failed", NotificationType.Error)
    )
    
     
  • Nirav (Akira28) Profile Picture
    Nirav (Akira28) 118 on at
    How to submit a new form and edit form together?
    Hi ratas101 ,

    May be you can try this one, if it works 🤞 (on Submit button)

    If(
        !IsBlank(Form1.LastSubmit), 
        Patch(
            'Tracker', 
            Form1.LastSubmit, 
            Form1.Updates, 
            Form2.Updates
        ),
        Notify("No existing record to update", NotificationType.Error)
    );
    Navigate('Success screen');


    ​​​​​​​If this post solved your issue, clicking 'Does this answer your question' will help others discover the solution and close the topic. If you found it helpful, a Like would be awesome!



    Regards,
    Nirav J Raval (Akira28)
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,246

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,884

Leaderboard