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...
Solved! Go to Solution.
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
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
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.
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
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.
Hermant,
I know I was the person to post it.
@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 🙂
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
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |