locked
How to hide the New Opportunity button on the Opportunities area on the Contact form? RRS feed

Answers

All replies

  • You could just clear the lookup value when the potential customer is of type contact, this would force the users to then select a new value.
    MSCRM Bing'd - http://bingsoft.wordpress.com
    Wednesday, August 11, 2010 3:55 PM
    Moderator
  • Hi.

    Try this - http://blog.davehawes.com/post/2008/04/23/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx

    This code worked fine for me.

    Also you can add following code to onload on opportunity:

    if (crmForm.FormType == 1 && crmForm.all.customerid.DataValue != null && crmForm.all.customerid.DataValue[0].typename == 'contact')

    {

    crmForm.all.customerid.DataValue = null;

    }

     

    I must warn you what you will have issues with Lead qualification dialogue.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, August 11, 2010 3:58 PM
    Moderator
  • Thanks Andriy, what ID did you try using for the New Opportunity button? I tried "NavOpps" and "_MBlocAddRelatedToNonForm32GUID" but neither seemed work. My customer doesn't use leads, but I'll add your warning to my code's comments just in case they use leads later.

    If I can't hide the button, I'll clear the value if the Potential Customer (Primary Company) field using your sample (like Rhett suggested).

    Thanks!


    Neil Benson, CRM Addict and MVP at Customery Ltd.You can reach me on LinkedIn or Twitter.

    Wednesday, August 11, 2010 5:05 PM
    Moderator
  • Try to use following code, Neil:

    HideAssociatedViewButtons(['Add a new Opportunity to this record']);
     
    function HideAssociatedViewButtons(buttonTitles){
      var navElement = document.getElementById('navOpps'); 
      if (navElement != null)  {
        navElement.onclick = function LoadAreaOverride()    {
          loadArea('areaOpps');
          HideViewButtons(document.getElementById('areaOppsFrame'), buttonTitles);
        }
      }
    }
    
    function HideViewButtons(Iframe, buttonTitles) {
      if (Iframe != null ) {
        Iframe.onreadystatechange = function HideTitledButtons() { 
          if (Iframe.readyState == 'complete') { 
            var iFrame = frames[window.event.srcElement.id]; 
            var liElements = iFrame.document.getElementsByTagName('li'); 
     
            for (var j = 0; j < buttonTitles.length; j++) { 
              for (var i = 0; i < liElements.length; i++) { 
                if (liElements[i].getAttribute('title') == buttonTitles[j]) { 
                  liElements[i].style.display = 'none'; 
                  break; 
                }
              } 
            } 
          } 
        } 
      }
    }
    
    It worked fine for me.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, August 11, 2010 9:40 PM
    Moderator
  • Hi,

    I have used following code to Hide new order button on Opportunity form ..see if you use this example on contact form...

     

    areaOrdersFrame_OnReadyStateChange =

    function()

    {

    if

     

    (this.readyState == "complete")

    {

    /* This is the frame we're interested in */

    var

     

    frame = document.frames("areaOrdersFrame");

    if

     

    (frame !=null)

    {

     

    /* And this is the new order button on form */

    var

     

    newOrderButton = frame.document.getElementById("_MBparentcustomAddRelatedItem21");

    if

     

    (newOrderButton !=null)

    {

    newOrderButton.style.display =

    'none';

    newOrderButton.nextSibling.style.display =

    'none';

    }

     

    }

    }

     

    }

    /* Set a new onclick event for the History navigation element

    * This is where we register the onreadystatechange event handler */

    if

     

    (document.getElementById('navOrders') != null) {

    document.getElementById(

    'navOrders').onclick = function() {

    loadArea(

    'areaOrders');

    document.frames(

    'areaOrdersFrame').document.onreadystatechange = areaOrdersFrame_OnReadyStateChange;

    }

    }

     

     


    MayankP My Blog My twitter
    Thursday, August 12, 2010 8:34 AM