cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
_kikilalaaa
Level: Powered On

OnFailure Form does not function?

Hi, 

 

I have a form, where user are required to select year dropdown and month dropdown before they fill in the detailed data. if user choose to add new form, and select same year and month that they have in the sharepoint list, a notification message should pop up saying that "This record has exists!"

 

I have configured the powerapps as below:

 

Form: OnFailure --> If(
!(IsBlank(
LookUp(Filter('SP List', And(Year=RecordedYear.Selected.Result,Month=RecordedMonth.Selected.Result))
)),
Notify(
"The record for this year exists!",
NotificationType.Error
),
true

 

However this does not function. Does anyone knows if i missed something?

4 REPLIES 4
Super User
Super User

Re: OnFailure Form does not function?

@_kikilalaaa 

I think your OnFailure code is not meeting the conditions to be triggered.  OnFailure fires when some rule in the SharePoint column is broken in SharePoint List >List Settings > Column Settings.

 

I don't think there's a way to set that specific condition in your SharePoint list so I would suggest moving your code to the OnSelect property of your submit button and checking if the error condition is met prior to submission.

 

If(
!(IsBlank(LookUp(Filter('SP List',
And(Year=RecordedYear.Selected.Result,Month=RecordedMonth.Selected.Result)))),
Notify("The record for this year exists!",NotificationType.Error),
SubmitForm(Form1)
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Dual Super User
Dual Super User

Re: OnFailure Form does not function?

Hi @_kikilalaaa 

 

OnFailure is only triggered when the form has failed. If you are looking for a way to stop the form from submitting, you need to add this on the Submit button, to show notification if the record exists like:

If(CountRows(Filter('SP List', And(Year=RecordedYear.Selected.Result,Month=RecordedMonth.Selected.Result))) = 0,
SubmitForm(FormName),
Notify(
"The record for this year exists!",
NotificationType.Error
))

Also, I have changed you expression a bit on the expression part, because LookUp(Filter()) is not the right way to check for the records.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

_kikilalaaa
Level: Powered On

Re: OnFailure Form does not function?

Hi @yashag2255 , I do not think it works because it gives me this warning.

but may i know why i cannot use lookup tho?

_kikilalaaa
Level: Powered On

Re: OnFailure Form does not function?

I have tried this way instead but it also shows error pop up when there are no record for that month.

 

Refresh('SP List');
If(
!(IsBlank(LookUp(Filter('SP List', Dept = varDept),And(Year=RecordedYear.Selected.Result,Month=RecordedMonth.Selected.Result)))),
Notify("The record for this year exists!",NotificationType.Error),
SubmitForm(Form1));
ResetForm(Form1);

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,452)