javascript - Getting Id of Ribbon Button In CRM 2011 - Stack Overflow

I created one javascript in which i want to hide ribbon Reactivate Lead button dependingon some condi

I created one javascript in which i want to hide ribbon Reactivate Lead button depending on some condition.

I got the Id of the button by pressing F12 on form which is lead|NoRelationship|Form|Mscrm.Form.lead.ReactivateLead-Large .

In jscript , to get that button -

document.getElementById("lead|NoRelationship|Form|Mscrm.Form.lead.ReactivateLead-Large");

but I am not getting that button, its giving me null .. I am not getting what is the problem . please let me know if anybody has suggetions.

thanks

I created one javascript in which i want to hide ribbon Reactivate Lead button depending on some condition.

I got the Id of the button by pressing F12 on form which is lead|NoRelationship|Form|Mscrm.Form.lead.ReactivateLead-Large .

In jscript , to get that button -

document.getElementById("lead|NoRelationship|Form|Mscrm.Form.lead.ReactivateLead-Large");

but I am not getting that button, its giving me null .. I am not getting what is the problem . please let me know if anybody has suggetions.

thanks

Share Improve this question edited May 25, 2013 at 23:01 Ry- 225k56 gold badges492 silver badges499 bronze badges asked Apr 18, 2011 at 10:22 Geet BGeet B 211 silver badge3 bronze badges 1
  • crm-2011 The ribbon button cannot be hidden using Jscript. Try this instead powerobjects./blog/2011/06/17/… – David Edokpayi Commented May 25, 2012 at 15:09
Add a ment  | 

5 Answers 5

Reset to default 3

The reason why you retrieve a null value is because the ribbon menu is displayed asynchronously. So if you try to retrieve the button when the onload event of the form is triggered, the button won't necessarily be in the DOM already.

The link provided by Luke will show you the right way to do this.

This should work, but you might need to hold your nose whilst using it

function HideARibbonButton(nameOfButton) {
    var intervalId = window.setInterval(function () {
        if (window.top.document.getElementById(nameOfButton) != null) {
            window.clearInterval(intervalId);

            //top menu has loaded
            window.top.document.getElementById(nameOfButton).style.visibility = 'hidden';
        }
    }, 100);
}

You can hide buttons in CRM2011 by altering the Entity customization XML.

Have a look at this: http://gtcrm.wordpress./2011/02/23/hiding-a-ribbon-button-in-crm-2011/

I also found that if you don't use window.top before document.. it doesn't always work.

My code always starts with window.top.document etc..

see below:

tabSave = window.top.document.getElementById("salesorder|NoRelationship|Form|Mscrm.Form.salesorder.MainTab.Save");

You are getting null because the ribbon takes some time to display so you have to set an interval (code to be executed every 2 second for example) in which you place your code which will hide the button.

Or, you can display rule which control the visibility of the button depending on the Boolean value returned by a java script function

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743761882a4502782.html

相关推荐

  • javascript - Getting Id of Ribbon Button In CRM 2011 - Stack Overflow

    I created one javascript in which i want to hide ribbon Reactivate Lead button dependingon some condi

    6天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信