Hi All,
I am using Xrm.Page.getControl("fieldname").setNotification("Invalid"); for show the error notification on field in JavaScript. It is working fine.
But Xrm.Page.getControl("cyno_startdate").clearNotification() is not working for clear notification in Dynamics 365.
If, I am using this alert(Xrm.Page.getControl("cyno_startdate").setNotification("Invalid Start Date")). Its return false.
Please suggest any solution ASAP.
Thanks!
*This post is locked for comments
Hi Ankit,
I had one scenario that one you give more then 10-digit phone numbers it will give the warning even you are giving any alpha value as well.
Code: https://juniorcrmblog.blogspot.com/2022/12/how-to-make-field-only-take-10-digit.html
In this code i have use setFieldNotification.
Note : I have latest dynamic crm interview question.
https://juniorcrmblog.blogspot.com/2021/08/ms-dynamic-crm-interview-question-for-2.html
And This day I do video on dynamic DCRM.
Call workflow directly from a button using Ribbon Workbench - YouTube
You really shouldn't be running with any code not working in turbo forms in 365. Who knows when the option to run legacy form will go away...
Can you try this below method. Which is working fine for me. Make sure u enabled legacy form rendering as well.
function commonEventHandler(executionContext) {
var entityObject = executionContext.getFormContext().data.entity;
var telephoneAttr = entityObject.attributes.getByName('telephone1');
var isNumberWithCountryCode = telephoneAttr.getValue().substring(0, 1) === '+';
// telephoneField will be an Xrm.Page control if invoked from a form OnChange event;
// telephoneField will be a editable grid GridCell object if invoked from editable grid OnChange event.
var telephoneField = telephoneAttr.controls.getByIndex(0);
if (!isNumberWithCountryCode) {
telephoneField.setNotification('Please include the country code beginning with ‘+’.', ' ');
}
else {
telephoneField.clearNotification('countryCodeNotification');
}
}
It's a pug with Legacy form rendering. I Don't know any workaround.
Hello.
Please use:
Xrm.Page.getControl(arg).clearNotification(uniqueId);
https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_clearnotification
Regards.
No. I used another solution for this now.
Did you get a solution . I am facing same issue in dynamics 365
Hi Hemant,
I have also tried that.
Hi Ankit,
If form notifications are working for you then You can try setting some value when you show form notification and clear notifications something like var iserror = true/false. And then finaly in save, you check this value and prevent save accordingly
Have not tried this but belives this should work. Worth trying.
Hi Ankit,
This should work.
Xrm.Page.getControl("fieldname").setNotification("message");
Xrm.Page.getControl("fieldname").clearNotification();
And you can't prevent Save by setFormNotification.
The field notification will help you if you want to prevent Save.
And one more thing I noticed,When tab is collapsed then the above code dont work.
Thanks
Hemant
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156