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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch with navigate, s...
Power Apps
Unanswered

Patch with navigate, stay on page if there is an error

(0) ShareShare
ReportReport
Posted on by 193

I use a patch process to submit multiple forms to the same sharepoint list. It works Great! One problem i have is that when I patch, I navigate back to the new screen. If there is an error in the patch, (Required field not chosen) the form navigates away from the page anyway. How can I get it to stay on the page if there is an error, even if I am using navigate in the patch process?

Categories:
I have the same question (0)
  • Verified answer
    v-xida-msft Profile Picture
    on at

    Hi @Roberts2727,

    Do you want not to navigate to another screen when there is error with the Patch function within your app?

     

    If you don't want to navigate to another screen when there is error with the Patch function within your app, I think the Errors function could achieve your needs.

    I have made a test on my side, please take a try with the following workaround:2.JPG

    Note: I don't provide a value for the Title column, which is a Required/mandatory fild in my SP list.

    Set the OnSelect proeprty of the "Vote" button to following formula:

    If(
     IsEmpty(
    Errors(
    '20181010_case4', /* <-- 20181010_case4 represents my SP list data source */
    Patch('20181010_case4',Defaults('20181010_case4'),{Visitors_x0020_Name:"Steven Liu",Company:"SunShine",Checkin_x0020_DateTime:Now()})
    )
    ), Navigate(NoErrorScreen,ScreenTransition.Cover), Navigate(HasErrorScreen,ScreenTransition.Fade) )

    On your side, you should type the following fomula within the "Submit" button:

    If(
     IsEmpty(
    Errors(
    'YourSPList', /* <-- 20181010_case4 represents my SP list data source */
    Patch(
    'YourSPList',
    Defaults('YourSPList'),
    {
    Column1: "xxx",
    Column2: "xxxx",
    Column3: "xxx",
    ...
    }
    )
    )
    ), Navigate(AnotherScreen,ScreenTransition.Cover) )

    The GIF screenshot as below:Test1.gif

    In addition, you could also take a try with the following formula within the OnSelect property of the "Submit" button:

    Patch(
     'YourSPList',
     Defaults('YourSPList'),
     {
     Column1: "xxx",
     Column2: "xxxx",
     Column3: "xxx",
     ...
     }
    );
    If(
    IsEmpty(Errors('YourSPList')),
    Navigate(AnotherScreen,ScreenTransition.Cover)
    )

    More details about the Errors function in PowerApps, please check the following article:

    Errors function

     

    Best regards,

    Kris

  • Roberts2727 Profile Picture
    193 on at

    @v-xida-msft

    I have tried both methods you propose with out success. Although I see the red banner throwing the error, I still navigate to the welcome screen. 

     

    below is my patch

     

    If(
     IsEmpty(
     Errors(
     ResearchApp, 
     
     Patch(ResearchApp, Defaults(ResearchApp),{Form2.Updates, Form3.Updates, Form3_1.Updates, Form3_2.Updates, Form3_3.Updates, Form3_4.Updates})
     )
     ), 
     
     Navigate(Welcome, ScreenTransition.Fade))

    Error with navigation back to welcome screen:

     

    Capture.PNG

     

    Thank you so much for your assistance. 

  • v-xida-msft Profile Picture
    on at

    Hi @Roberts2727,

    Could you please share your app with me?

    I have made a test on my side, and don't have the issue that you mentioned.

    Please take a try to re-create your app, then check if the issue is solved.

     

    Best regards,

    Kris

  • Roberts2727 Profile Picture
    193 on at

    Ohh I got it! I removed the curly brackets around my forms and reformatted for readability. 

     

    If(
     IsEmpty(
     Errors(
     ResearchApp, 
     Patch(
     ResearchApp,
     Defaults(ResearchApp),
     
     Form2.Updates, 
     Form3.Updates, 
     Form3_1.Updates, 
     Form3_2.Updates, 
     Form3_3.Updates, 
     Form3_4.Updates
     
     )
     )
     ), 
     Navigate(Welcome, ScreenTransition.Fade)
     )

    You are amazing Kris! 

  • PytByt Profile Picture
    943 on at

    Hi @v-xida-msft and @Roberts2727 

    I'm trying to implement you solution with my case, which is :

    If patch return a records, means journal counting line was updated. End of the process (use Error function to have patch return value),
    If no record returned, mean you need to create journal counting line, so patch again with Default (using patch default as else expression)

    And i'm trying with this code below, and it doesnt work:
    If(
    IsEmpty(
    Errors(InventoryCountingJournalLines,
    ForAll(ScanColl, Patch(InventoryCountingJournalLines,
    LookUp(InventoryCountingJournalLines, JournalNumber = Journals.SelectedText.Journal
    && ItemNumber=item_id && InventorySiteId=item_site
    && WarehouseId=item_warehouse && WarehouseLocationId=item_location),
    {CountedQuantity:item_count})))
    ,
    ForAll(ScanColl, Patch(InventoryCountingJournalLines,
    Defaults(InventoryCountingJournalLines),
    {JournalNumber: Journals.SelectedText.Journal,
    ItemNumber: item_id,
    ItemBatchNumber: item_batchnumber,
    InventorySiteId: item_site,
    WarehouseId: item_warehouse,
    WarehouseLocationId: item_location,
    CountedQuantity: item_count}))))

    What should i fix?
    Please help.

     

    Thanks.

    pytbyt

  • OvidiuC Profile Picture
    5 on at

    Hello,

    I'm new to Power Apps and I have the same issue, I have a form with multiple screens and when submitting a screen will go to the next one even if the mandatory fields are not filled.

    I tried the mentioned solutions without success.

    I have Screen1 with Form1 and the default formula used was SubmitForm(Form1) & Navigate(Screen1_1)

     

    When I tried the below solution it didn't work

    If(
    IsEmpty(
    Errors(

    'Quality Check',
    Patch(
    'Quality Check',
    Defaults('Quality Check'),
    {
    Column1: "xxx",
    Column2: "xxxx",
    Column3: "xxx",
    ...
    }
    )
    )
    ),
    Navigate(Screen1_1,ScreenTransition.Cover)
    )

     

    Instead of column 1, 2 ,3 I entered the columns from my form and still dind't work, not sure about "xxx" is there supposed to be a value?

     

    Thank 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard