Hi Team,
I have registered a Javascript function "validateYear" on the OnChange event of the year field. I am doing a validation like if the year field has less than 4 characters then alert the user.
Action Performed : On the Form, i entered year as 12
Expected Result :
validateYear function is triggered and execute #line from 2 to 6.
execute #line 7 and sets the year as empty string. so this will again trigger that validateYear function. This time when the #line 2 gets executed it is expected to have the year as empty string and it should not execute the line 3.
Actual Result :
validateYear function is triggered and execute #line from 2 to 6.
execute #line 7 and sets the year as empty string. so this will again trigger that validateYear function. This time when the #line 2 gets executed it still holds the year value as 12 .
Code Below :
- function validateYear() {
- var year = Xrm.Page.getAttribute("year").getValue(); //This is not getting the right value when the event is again triggered due to change in value of the year on line 7.
- if (year != null && year != "") {
- if (year.length < 4) {
- //Alert
- Xrm.Utility.alertDialog("Please enter a valid Year", function () { });
- Xrm.Page.getAttribute("year").setValue(""); // This line will trigger the onchange event function validateYear
- return;
- }
- }
- }
I guess this is a Microsoft bug on the crm 2016 online 8.1 version. As anyone face this same issue ?
Thanks & Regards,
Awad.
*This post is locked for comments