Hello All,
On Entry of Second Marking Marks.
i need an Alert in JS if First Marking Marks and Second Marking Marks difference is 5% or more.
Hello All,
On Entry of Second Marking Marks.
i need an Alert in JS if First Marking Marks and Second Marking Marks difference is 5% or more.
Hi Sandee,
A check script code could be below:
function checkDifference(executionContext) { var formContext = executionContext.getFormContext(); var maximumMarks = 100; var firstMark = formContext.getAttribute("new_firstmarkingmarks").getValue(); var secondMark = formContext.getAttribute("new_secondmarkingmarks").getValue(); if (firstMark >= 0 && secondMark >= 0) { var differenceRate = Math.abs(firstMark - secondMark) / maximumMarks; if (differenceRate >= 0.05) { var message = { confirmButtonLabel: "Close", text: "Difference rate is larger than 5%." }; var alertOptions = { height: 150, width: 250 }; Xrm.Navigation.openAlertDialog(message, alertOptions).then( function success(result) { console.log("Alert dialog closed"); }, function(error) { console.log(error.message); } ); } } }
Result:
Remember enable the option:
Note:
I just fire the function at form onLoad event, you may attach it to these two fields onChange event as suggested anwser.
Hope it helps,
Regards,
Clofly
ok let me try
Hi,
Put onChange event on both fields First Marking Marks and Second Marking Marks (as I know you are creating custom hTML)
On That onChange
get value Through ID for First Marking Field and Same for Second Marking Field using JQuery
and After that Check that ((Second Marking Field Value/Maximum Marks) - (First Marking Field Value/Maximum Marks) * 100) > 5.0
Show alert
OR
if the Maximum Marks is 100 So no need to do Just do with Straight Formula
if ( Second Marking Field Value - First Marking Field Value) > 5
Show alert
section 1 obtained marks is first markings. section 2 obtained marks is second markings. if the difference between these two markings is 5% or more an alert should be shown
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,403
Most Valuable Professional
nmaenpaa
101,156