cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ben-thompson
Level 8

Use SetNotification to show error messages?

Is it possible to access SetNotification within a field control to display an error message if required (say in a bound control when the number is out of range)? This would ensure the error message would be displayed at the top of the form were someone to try and save the record while the error existed.

 

Now logged as an idea at https://powerusers.microsoft.com/t5/PowerApps-Ideas/Allow-a-PCF-field-component-to-flag-a-field-as-i...

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff AnqiChen
PowerApps Staff

Re: Use SetNotification to show error messages?

hi Ben,

 

Thanks for your nice explaination and providing the real situation that a control with regular expression input should bundle together. This is a very valuable feedback!

 

To realize the scenario, I think your ask is:

1) Officially expose setNotification from control side

2) Whenever setNotificatin is being called, block form save

 

We value your feedback, please confirm if this is the ask

 

Thanks,

Anqi

 

 

View solution in original post

10 REPLIES 10
PowerApps Staff AnqiChen
PowerApps Staff

Re: Use SetNotification to show error messages?

hi Ben,

 

Here is what my understanding, hopefully it helps,

 

1. If the field is a number field with a static range, then if the output it out of the range, it will show error message and blocks the form save.

 

2. Could a field custom control access SetNotification?

Yes, it could, but we did not expose this API. It should be ‘context.utils.setNotification’

 

3. Could a field customcontrol call setNotification and block the form save together?

We currently did not block form save when setNotification is from a control.

But when clientAPI setNotification, it will block form save.

 

4. If a field violates dynamic range, a notification should show and form should block save, is there any work-around on achieving this?

 

Yes, whenever user output data, it triggers clientAPI, and clientAPI triggers setNotification

 

User’s custom control could have 3 properties and could bound to 3 attributes in the form

 

<property name=’value’   bound to the current field

<property name=’max’ bound to a hidden ‘dynamic max’ field

<property name=’min’ bound to a hidden ‘dynamic min’ field

 

The  ‘current field value’ clientAPI onChange handler will need to check its value is in dynamic range and set/clear notification accordingly.

 

Feel free to ask follow-up question or IM me if details is needed

 

Anqi

dmonks
Level: Powered On

Re: Use SetNotification to show error messages?

 
ben-thompson
Level 8

Re: Use SetNotification to show error messages?

Anqi, thanks for that it answers my question but also doesn't answer it.

 

Both @ashlega  (with his regular expression question elsewhere) and myself seem to be looking at creating controls where the logic to ensure the value entered is valid is fully contained within the control itself. 

 

By storing the validation logic within the control rather than within the client api it would be possible to move validation from a code (javascript) or low code (business rules) to a zero code solution where all a user is required to do would be to create the field, add it to a form and change the control type (say) from a standard textfield to a range limited or regular expression textfield, add the validation critiera and the field will be ready to go. 

 

I will add an appropriate post in the ideas section.

PowerApps Staff AnqiChen
PowerApps Staff

Re: Use SetNotification to show error messages?

hi Ben,

 

Thanks for your nice explaination and providing the real situation that a control with regular expression input should bundle together. This is a very valuable feedback!

 

To realize the scenario, I think your ask is:

1) Officially expose setNotification from control side

2) Whenever setNotificatin is being called, block form save

 

We value your feedback, please confirm if this is the ask

 

Thanks,

Anqi

 

 

View solution in original post

ben-thompson
Level 8

Re: Use SetNotification to show error messages?

Yes that would be my ask:-

expose setNotification on the control side

ensure that setNotification works as it does on the Client API side and stops the page from saving until the notification is cleared.

 

Thanks.

Highlighted
PowerApps Staff HemantG
PowerApps Staff

Re: Use SetNotification to show error messages?

ben-thompson
Level 8

Re: Use SetNotification to show error messages?

Hermant,

 

I know I was the person to post it.

PowerApps Staff HemantG
PowerApps Staff

Re: Use SetNotification to show error messages?


@ben-thompson wrote:

Hermant,

 

I know I was the person to post it.


Ha ha I know, this is for everyone else. You need votes too 🙂

Yawer
Level: Powered On

Re: Use SetNotification to show error messages?

Thanks @AnqiChen this reply is helpful. Asking a couple of further relevant questions please:

 


@AnqiChen wrote:

 

2. Could a field custom control access SetNotification?

Yes, it could, but we did not expose this API. It should be ‘context.utils.setNotification’

Are you saying you this API is not documented for public use but available or it is something new and will be released in future?

 


Yes, whenever user output data, it triggers clientAPI, and clientAPI triggers setNotification

 

User’s custom control could have 3 properties and could bound to 3 attributes in the form

 

<property name=’value’   bound to the current field

<property name=’max’ bound to a hidden ‘dynamic max’ field

<property name=’min’ bound to a hidden ‘dynamic min’ field

 

The  ‘current field value’ clientAPI onChange handler will need to check its value is in dynamic range and set/clear notification accordingly

 

Instead of JS on change of current field value, as per current infrastructure can it form level? On form load hocking onSave, check data- and if found don't save? 

 

Thanks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,920)