web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

More than one time alert box appear

(0) ShareShare
ReportReport
Posted on by 1,347

Hi,

 i throw alert message in ms crm using javascript , alert message having ok,cancel button if i press "ok" alert message not disappear it appear again ,the alert message appear three times how to resolve it

*This post is locked for comments

I have the same question (0)
  • Iswarya Profile Picture
    1,347 on at
    RE: More than one time alert box appear

    Hi ,

    thanks for your suggestion:)

  • Verified answer
    SCV Profile Picture
    1,004 on at
    RE: More than one time alert box appear

    Hi,

    This happens because you are setting copstatus in your code which triggers your function again.

    Xrm.Page.getAttribute("tct_copstatus").setValue(null); 

    So I would suggest you to do some workaround for this; similar to this:


    var CopStatusSetByCode; function CopStatus() { if (CopStatusSetByCode == false) { debugger; var TodayDate = new Date(); var ExpiryDate = Xrm.Page.getAttribute("tct_copexpirydate").getValue(); var copStatus = Xrm.Page.getAttribute("tct_copstatus").getValue(); //if (copStatus != null || copStatus != undefined || copStatus != "") // return; if (ExpiryDate != null && copStatus != null || copStatus != undefined || copStatus != "") { if (ExpiryDate < TodayDate) { alert("The COP Status cannot be modified."); CopStatusSetByCode = true; Xrm.Page.getAttribute("tct_copstatus").setValue(null); } else if (ExpiryDate >= TodayDate) { if (copStatus == 2) { alert("Please attach the relevant supporting documentation for the COP Update"); } } } } }


     

     

  • Verified answer
    SreeniPavalla Profile Picture
    195 on at
    RE: More than one time alert box appear

    Hi ,

    This Javascript method fires on change of status. And you are changing the status again in your javascript. So only alert message is coming. To prevent this use flag which tells you that the call is 2nd time or first time. Based on this you can prevent alter. Let me know if you need more details

  • Iswarya Profile Picture
    1,347 on at
    RE: More than one time alert box appear

    Hi,

    function CopStatus()
    {
        debugger;
        var TodayDate = new Date();
        var ExpiryDate = Xrm.Page.getAttribute("tct_copexpirydate").getValue();
        var copStatus = Xrm.Page.getAttribute("tct_copstatus").getValue();
        //if (copStatus != null || copStatus != undefined || copStatus != "")
        //    return;
        if (ExpiryDate != null && copStatus != null || copStatus != undefined || copStatus != "")
        {
            if (ExpiryDate < TodayDate)
            {        
              
                alert("The COP Status cannot be modified.");
                Xrm.Page.getAttribute("tct_copstatus").setValue(null);
                
            }
            else if (ExpiryDate >= TodayDate) {
            
              if (copStatus == 2)
              {
                  alert("Please attach the relevant supporting documentation for the COP Update");
                 
              }
            }
        }
        

    }

    i call this function in status field onchange

  • Community Member Profile Picture
    on at
    RE: More than one time alert box appear

    Can you paste your code here so that we can take a look at it?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans