locked
Hide Deactivate button from Associated view/More actions RRS feed

  • Question

  • I want to hide deactivate button from associated view / more actions.
    Thursday, September 16, 2010 12:52 PM

Answers

  • you need to use below code on contact form load

    var item = document.getElementById('IDofDeactivateOption');
    if(item!=null)
    item.style.display='none';

    to pick ID you need to follow below steps

    1. Open contact record.

    2.Press F11 you will get address bar

    3. Copy address and paste it in browser

    4. Then you can use Developer toolbar to get id of deactivate menu option

    let me know if you need any other information


    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 16, 2010 1:09 PM
    Moderator
  • It wont work, you have to load the associated view area using loadarea function and then attach More Actions (onclick) to disable the deactivate button..... CRM doesnot load until you perform some action

    function
     HideAssociatedViewButtons(loadAreaId, buttonTitles){
    
      var
     navElement = document.getElementById('nav_'
     + loadAreaId); 
    
      if
     (navElement != null
    )  {
    
        navElement.onclick = function
     LoadAreaOverride()    {
    
          // Call the original CRM method to launch the navigation link and create area iFrame
    
    
          loadArea(loadAreaId);
    
           <Call the above code here>
    
    
        }
    
      }
    
    }
    

    Hope this helps. Amar
    Thursday, September 16, 2010 4:14 PM
  • It may be too late for the original poster, but considering that the record could be deactivated from other locations and other ways, perhaps the best way to prevent Deactivation would be to write a Plugin that attaches to the SetState and SetStateDynamicEntity messages for this entity, and checks whether or not the target State is an Inactive one, and denies it for users without a specific Security Role.
    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com
    Saturday, November 6, 2010 12:43 AM
    Moderator

All replies

  •  

    Please check the following post for the same

     

    http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/0cdd7d3b-4514-486c-a8d2-ceaf58a1c0bd


    Hope this helps. Amar
    Thursday, September 16, 2010 1:00 PM
  • Thanks for the reply Amarsen,

     

    Nut I already go through this post. this post is for main page view more action. I want to 

    hide for Associated view.

    Thursday, September 16, 2010 1:02 PM
  • you need to use below code on contact form load

    var item = document.getElementById('IDofDeactivateOption');
    if(item!=null)
    item.style.display='none';

    to pick ID you need to follow below steps

    1. Open contact record.

    2.Press F11 you will get address bar

    3. Copy address and paste it in browser

    4. Then you can use Developer toolbar to get id of deactivate menu option

    let me know if you need any other information


    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 16, 2010 1:09 PM
    Moderator
  • Thanks Mahendra! I got the Id i.e. MoreActions

    and I use this code

    var item = document.getElementById('MoreActions');

    if(item!=null)

    item.style.display='none';

    But it is not working. 
    The above code is for Hide More Action option. If I want to hide it sub menu option i.e. 'Deactivate' than how to take the Id of Deactivate option.
    please help me on this.

    Thursday, September 16, 2010 2:21 PM
  • Hey,

    you can get id of deactivate menu option in the same way as you got for moreaction check for list items ids


    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 16, 2010 2:27 PM
    Moderator
  • But still Menu option is also not get deactivated from above code in associated view.
    Thursday, September 16, 2010 2:29 PM
  • please use

     item.style.disabled = true;


    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 16, 2010 2:32 PM
    Moderator
  • Sorry Mahendra, but this is also not working.
    Thursday, September 16, 2010 2:44 PM
  • It wont work, you have to load the associated view area using loadarea function and then attach More Actions (onclick) to disable the deactivate button..... CRM doesnot load until you perform some action

    function
     HideAssociatedViewButtons(loadAreaId, buttonTitles){
    
      var
     navElement = document.getElementById('nav_'
     + loadAreaId); 
    
      if
     (navElement != null
    )  {
    
        navElement.onclick = function
     LoadAreaOverride()    {
    
          // Call the original CRM method to launch the navigation link and create area iFrame
    
    
          loadArea(loadAreaId);
    
           <Call the above code here>
    
    
        }
    
      }
    
    }
    

    Hope this helps. Amar
    Thursday, September 16, 2010 4:14 PM
  • Sorry Amar, but I didn't get, where should I use this code.
    Friday, September 17, 2010 5:24 AM
  • Try to put this code on form load
    Mahain : http://mahenderpal.wordpress.com
    Friday, September 17, 2010 5:57 AM
    Moderator
  • But how the function HideAssociatedViewButtons() get called
    Friday, September 17, 2010 11:04 AM
  • you have to call it in formload itself
    Mahain : http://mahenderpal.wordpress.com
    Friday, September 17, 2010 11:20 AM
    Moderator
  • Sorry Amar but it is not working.
    Friday, September 17, 2010 11:27 AM
  • Mahendra , I tried it on form load but it is not working....
    Friday, September 17, 2010 11:28 AM
  • It may be too late for the original poster, but considering that the record could be deactivated from other locations and other ways, perhaps the best way to prevent Deactivation would be to write a Plugin that attaches to the SetState and SetStateDynamicEntity messages for this entity, and checks whether or not the target State is an Inactive one, and denies it for users without a specific Security Role.
    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com
    Saturday, November 6, 2010 12:43 AM
    Moderator