Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Alert if First Marking Marks and Second Marking Marks difference is 5% or more

(0) ShareShare
ReportReport
Posted on by 5,091

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.

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Alert 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:

    pastedimage1571641513873v1.png

    Remember enable the option:

    007.jpg

    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

  • sandeepc Profile Picture
    sandeepc 5,091 on at
    RE: Alert if First Marking Marks and Second Marking Marks difference is 5% or more

    ok let me try

  • Verified answer
    ajyendra Profile Picture
    ajyendra 1,732 on at
    RE: Alert if First Marking Marks and Second Marking Marks difference is 5% or more

    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

  • sandeepc Profile Picture
    sandeepc 5,091 on at
    RE: Alert if First Marking Marks and Second Marking Marks difference is 5% or more

    h.PNG

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans