cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Roberts2727
Helper IV
Helper IV

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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-xida-msft
Community Support
Community Support

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@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. 

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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! 

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
Regular Visitor

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!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,391)