Resources for IT Professionals > Dynamics Forums > CRM Development > ISV.Config : find button based on Name
Ask a questionAsk a question
 

AnswerISV.Config : find button based on Name

  • Friday, November 06, 2009 4:41 PMMayankP Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi All,

    we have put new button on entity form using ISV.Config.

    Now our requirment is that we should hide this button in certain conditions, I know java script will do the job but unfortunately I am not able to find the particular button based on Id (becuase new Id will get generates everytime) and I have seen the thread where some provided method to get button based on element name..

    can any one please paste the code again? I have google it and found the syntax but still not working for my code..so any example code on how to find custom button on entity form based on name will be appreciated..

Answers

  • Friday, November 06, 2009 6:13 PMDavidBerry Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    I suppose you might be able to use some variation on Dave Hawes code:  http://blog.davehawes.com/post/2008/04/24/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx#continue

    Specifically, I would refactor it to something simple like:

                    var buttonTitles = new Array("Hide Me!");
                    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; 
    
                            }
    
                        } 
    
                    } 
    Not sure if it'll work in this situation, but give it a shot.
    Dave Berry

All Replies

  • Friday, November 06, 2009 6:13 PMDavidBerry Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    I suppose you might be able to use some variation on Dave Hawes code:  http://blog.davehawes.com/post/2008/04/24/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx#continue

    Specifically, I would refactor it to something simple like:

                    var buttonTitles = new Array("Hide Me!");
                    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; 
    
                            }
    
                        } 
    
                    } 
    Not sure if it'll work in this situation, but give it a shot.
    Dave Berry