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)

Ribbon Button Enable Rule - Custom Rule Step

(0) ShareShare
ReportReport
Posted on by 185

Hello Professionals,

I am worried why my JavaScript function which is bind to Custom Rule in Ribbon button gets called twice when page loads. This degrades page performance. Anybody knows and can help if there is anything to do or I am doing something wrong ?

Regards,

Zeshan Khan

SR. CRM Consultant

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Ribbon Button Enable Rule - Custom Rule Step

    Hi Zeshan,

    if you solved the problem thanks to an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: Ribbon Button Enable Rule - Custom Rule Step

    If you are talking about Enable Rule calling JavaScript function, unfortunately that is the way CRM currently calls enable rules on Custom JavaScript. I am not sure if this is a bug or by design (pre/post rule events), but there is nothing really that you can do regarding that.

    Francesco's response gives you a workaround if you have a long running script in your enable rule.

    Hope this helps.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Ribbon Button Enable Rule - Custom Rule Step

    Hi Zeshan ,

    it is certainly an issue caused by some wrong callback o recursive event.

    If you want to solve it fast, you could add a flag and trigger the function only once, like:

    var triggered = false;
    
    function RibbonButtonClick()
    {
        CallMyFunction();
    }
    
    function CallMyFunction() {
        if (triggered == false)
        {
            // never trigger it again!
            triggered = true;
            // ... your function body follows
            alert("Triggered!");
        }
    }

    Hope it helps!

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Thomas David Dayman Profile Picture
    11,323 on at
    RE: Ribbon Button Enable Rule - Custom Rule Step

    Is the JavaScript still being called onLoad in the Form settings? Theres no way that JavaScript should be getting called unless the Ribbon button is pressed.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans