Home » Javascript | MS CRM4

MSCRM 4 - Remove 'Add Existing xxxxx to this record' button

24. April 2008 by Dave Hawes 60 Comments

I've been working on a MS CRM 4 project and found that the custom entities that we added displayed an 'Add Existing xxxxx to this record' button when it was not required and created a lot of confusion among the users.

Microsoft have said they will make this optional 'In the next release' but that is not soon enough for me!

After working through various ideas on how to solve this with Ian Crowther and Steve Vallance we came up with the following fix. Thanks also to 'Dynamic Methods' for this post about hiding buttons: http://dmcrm.blogspot.com/2008/01/hiding-buttons-in-mscrm-40.html

This javascript should be added to the onLoad event for the form of the entity where you want to hide buttons for the associated views of other entities. You then need to call the function HideAssociatedViewButton for each associated entity - passing in the name of the dataArea div tag and the title of the button you need to remove. (this can be found by using the IE Developer toolbar):

The original code snippet (version 1) can be found here:

http://blog.davehawes.com/page/Remove-Add-Existing-xxxxx-to-this-record-button-version-1.aspx

This version (version 2) has been updated thanks to the contribution from David Berry. His code splits out the hiding of buttons when an iFrame is loaded into a separate function. It also allows multiple buttons to be hidden which is very useful as well as allowing the function to be used to hide buttons in other iFrames as well. Many thanks David.

Technorati Tags: ,

Comments

davehawes
United Kingdom davehawes said:

Thanks to Richard McCormick for resubmitting the code snippet after doing some de-phuglyfying on the orginal code. This has made it more readable and robust.

Cheers Rich!!

Alex
United States Alex said:

"This javascript should be added to the onLoad event of the entity."

How do you do that? There is an onload event for an entity's form. But I don't think you mean that...?

Thanks

davehawes
United Kingdom davehawes said:

Hi Alex,

It does go in the onload event for an entity's form.

Are you having problems getting this working? Could you let me know so I can clarify points in the blog.

Many thanks,

Dave

Sveta
United States Sveta said:

Hi

I liked your solution and it worked for me but I'd like to make a suggestion because I was confused when I read the article. In the article you say 'This javascript should be added to the onLoad event of the ... You then need to call the function removeExistingButton'. The last sentence is confusing. Your code doesn't have removeExistingButton() and doesn't need it.
Thanks for your help
Sveta

davehawes
United Kingdom davehawes said:

Thanks Sveta,

Yes the article was indeed confusing and needed updating as the 'removeExistingButton' function was renamed to 'HideAssociatedViewButton' when the code was refactored by Rich.

I've updated the post, I hope that it reads better now!

Tony C.
United States Tony C. said:

Any idea on how to make this work is the associated view is displayed in an IFRAME on the main entity form?  It works when accessing the associated view using the left nav. bar, but my IFRAME seems to ignore it, and still shows the "Add Existing XXXX" button.

David Berry
United States David Berry said:

This is an adjustment of the code Dave provided, that will provide usability outside of the "nav" IFrames.  This does and will work for embedded, Associated Views within an entity's main form:


// Hides buttons from view
function HideViewButtons(Iframe, buttonTitles) {
  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;
          }
        }
      }
    }
  }
}

// Change the source of our IFRAME
crmForm.all.IFRAME_KitProducts.src = GetFrameSource("my_custom_framename");

var hideButtons = ["Add existing Quote Kit Part to this record", "Add a new Quote Kit Part to this record"];

HideViewButtons(document.getElementById("IFRAME_KitProducts"), hideButtons);

trackback
Jeremy Winchell said:

Trackback from Jeremy Winchell

Hiding the Add Existing Button in a CRM 4.0 Grid

davehawes
United Kingdom davehawes said:

Thanks David for a further refactoring of the code - it is just getting better and better!

Simón
Spain Simón said:

Is there any way to hide the "Add existing Activity to this record" and "Add existing Contact to this record" buttons? I have hidden all the custom entities buttons but I can't hide "Activity" and "Contact" buttons.

Thanks.

mike
Germany mike said:

hi, david! your code is wonderful and it works fine for any 1:n-relationship, but i'm having problems when using it for n:n-relationships... they seem to be handled in a slightly different way... any suggestions?

Scott
United States Scott said:

I am finding with this code, that if I resize the form, the hidden button reappears.  My guess is that the IFRAM reloads but since the form itself does not reload, the script to hide does not execute again.

Any ideas how to make these buttons stay hidden?

Susan
United States Susan said:

Hi Dave,

There is a problem with the script above for hiding "add existing" buttons.
It works fine when the form is opened initially and the scripts loads at the "form on load " event.
But if u resize the form both vertically and horizontally,
Both the icons "add New" & "add existing" start showing up.

So that is a major problem with this one...

Is there any way we can make it work even after resizing the form...???

Thanks

Keith
Canada Keith said:

How do you get the IE Developers Toolbar to work with modal popups?  It doesn't show up so I can't get the id of the element I want to hide.  Any idea?

davehawes
United Kingdom davehawes said:

I'll just run through all the comments posted and answer the best I can:

Keith - IE Developer Toolbar - you should be able to press f11 to get the url of the modal box and then paste that into a full size browser window. See this entry by Ronald Lemmen <a href='ronaldlemmen.blogspot.com/.../...for-fetchxml.html'>ronaldlemmen.blogspot.com/.../...for-fetchxml.html</a>

Scott / Susan - The button reappearing when an IFrame resizing. I'm afraid I don't know about this. If either of you have a solution it would be great to know what it is. Unfortunately I'm not doing any CRM projects at the moment and won't have a chance to try and work this out until sometime early in the new year.

Mike - The n:n relationships again is something that I don't know about. If there is anyone who does it would be great to hear from you.

Simon - I'm afraid that I don't know about the Contacts and Activities without trying it out on a development environment which won't be for another month or so I'm afriad.

Thank you everyone for your comments and hopefully if someone has solved any of these problems they would be kind enough to post a comment with the solutions!

Bjorn
Bjorn said:

Hi,

Does anyone know what you could add to this script to remove the spacers with img ID: mnu_hSpacerGrid that are placed between the buttons. If you remove all buttons from an associated view, it's also nice to be able to remove the spacers.

Regards,
Bjorn

Theresa
United States Theresa said:

When calling the function HideAssociatedViewButtons, what is loadAreaId and where does it come from?  Thanks!

Susan
United States Susan said:

Hi,

I have analysed that the problem is resizing of the CRm forms when screen resolutions change.
Yet have not found any solution for the same.
But will keep u posted as I find one...
Till then Happy Blogging.....

Susan..

Yuan
Malaysia Yuan said:

hi. David

sorry, may i know how to know this field ('new_account_new_eventinvite') need fill what value?

HideAssociatedViewButtons('new_account_new_eventinvite', ['Add existing Event Invite to this record']);

thank you

bhavika
India bhavika said:

Hi dave,
I would like to know how to hide/remove "New" buton from an entity public view. I can give u an example..I have created one button "New opportunity" using ISV on opportunity entity which does same work as default "New" button does, i.e. it allows to create opportunity record.
Now I dot want teh CRM default button on my public default page.
How can I achieve this? There is no onload() event for default public view of CRM page.So here should i code?
please let me know if u have any idea

Ganesan
Singapore Ganesan said:

Hi Dav,

I am using ur code and trying to hide "Add existing Address to this record" button available on the "Contact" Entity associated view for the Address. Below is the code i am using

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);  
    HideViewButtons(document.getElementById(loadAreaId +'Frame'), buttonTitles);
    }  
  }
}

But i can able to see the Button over there, and even sometimes when i click addresses on the navigation and its not getting navigated to the grid.

Pls. do clarify me and give me one more example of the code and
where are they locations i have to call this method.

Thanks and Waiting For Your Reply,
Ganesan Nagarajan.




davehawes
United Kingdom davehawes said:

Another catchup post!

I'm still up to my eyeballs with my new venture http://www.safetytrainingnetwork.co.uk so have not done any CRM work for a few months. However I can see light at the end of the tunnel and am looking to get some contract work in the near future but I will try and answer the questions asked to the best of my ability.

Bjorn - I would have to look into this which I don't have time to do at the moment. I'm sure that it should be possible.

Theresa - The loadareaid is the first parameter passed into the function and is the id that the core CRM app needs to load the the page. I find out what this is by using the Internet Explorer developer toolbar and clicking on the left navigation control that launches the related entity screen.

Susan - Great stuff - please let me know if you find a solution!

Yuan - Please see my answer to Theresa. Using the IE Developer toolbar is the key here!

bhavika - This would require me to spend a decent amount of time to try and figure out, which I don't have at the moment I'm afraid. Hopefully in the next couple of months I'll be able to have a look at it for you.

Ganesan Nagarajan - I think I understand what you are asking. Are you calling the javascript funciton? For example:

HideAssociatedViewButtons('new_account_new_eventinvite', ['Add existing Event Invite to this record']);  

The first parameter is the AreaId (please see beginning of my comment on how to find this) and the second parameter is a string array of the tooltips of the buttons you want to hide. I hope that helps.

dml
United States dml said:

I'm new to this. I want to hide the "Add Existing...." button on a specific Status entity view.

Can I just cut/paste the "version 2" code into the OnLoad Event of the Status entity form properties w/o a problem? Is that all I need to do or do I need to find out some other kind of info.

thanks

Marc-Andre
Canada Marc-Andre said:

I'm not sure if it can be applied to this code, but I had the issue of buttons reapparearing (upon resize) in form's main toolbar, and my solution was to remove the button's node from the html DOM.
I'm not yet at the point of trying to do this here, but will need to test if it works soon. Will keep you posted.

Great post by the way.

Kostas
United Kingdom Kostas said:

Regarding the button re-appearing when you resize the form, the solution is to use this:
liElements[i].style.visibility = 'hidden';
instead of:
liElements[i].style.display = 'none';

I'm guessing that some other Javascript in the form changes the display property when you resize the form, but luckily it leaves the visibility property alone.

davehawes
United Kingdom davehawes said:

Top tip there Kostas! many thanks.

David Murdock
Canada David Murdock said:

Hi Dave,

First, thanks for handing out a clue to those of us who are full time coders.
I am trying to implement this solution of yours to hide the two Add new and Add existing buttons showing up in an Associated View.
I have already got an OnLoad script to open the Associated View into an IFRAME on the Main Tab of the Parent Entities Form.

The IFrame's Name is IFRAME_ProjectItems
The Button's Tool Tip Text's Are: "Add a new Project Item to this record", "Add existing Project Item to this record" respectively.

Here's the Code i'm attempting to use:
// Hides buttons from view
function HideViewButtons(Iframe, buttonTitles) {
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';
debugger;
break;
}
}
}
}
}
}

// Change the source of our IFRAME
crmForm.all.IFRAME_ProjectItems.src = GetFrameSource("IFRAME_ProjectItems");

var hideButtons = ["Add a new Project Item to this record", "Add existing Project Item to this record"];

HideViewButtons(document.getElementById("IFRAME_ProjectItems"), hideButtons);


My Question is: What should i be inserting into GetFrameSource() i'm pretty sure i'm using the wrong string.

Any help would be greatly appreciated.

Cheers,
Dave


My question is as follows.

davehawes
United Kingdom davehawes said:

Hi Dave,

So the difference here is that you are not using the standard associated view and are putting the view in an Iframe on the Parent.

Off the top of my head I am going to guess that there is an associated view iframe within your 'IFRAME_ProjectItems' iframe. You would need to write some code to find the associated view iframe before passing it into the HideViewButtons function.

Hope that helps - if anyone else reading this blog has had and solved this problem please can they help here ;)

Cheers,

Dave

David Murdock
Canada David Murdock said:

Dave,

Thanks for the reply. A correction from my first post: "are full time coders".. meant to say "aren't full time coders"
Probably makes more sense read that way.

I am using the "Standard" Associated View, just moving it to an IFrame on the General Tab of the Parent Entity.

Original was nav_New_Project_New_ProjectItems
Placed into 'IFRAME_ProjectItems' which is in a section on the General Tab of the Parent Entity.

I wish this were simpler. Those buttons are such a nuisance.

Anyways,
Thanks again for the help

Dave

Taj
Australia Taj said:

Hi Dave,

The code is not working if I change display name of the entity.
What I mean is, say I have an entity new_emp wiht default display name Emp, but later on if I change the display name Emp to People and use as follows --

HideAssociatedViewButtons('new_account_new_emp', ['Add existing People to this record']);

it doesn't hide add existing button

Matt Poland
United States Matt Poland said:

I updated the HideAssociatedViewButtons function to work with both system and custom entities.  (See how isNativeEntity changes processing)

function HideAssociatedViewButtons(loadAreaId, buttonTitles){
   var isNativeEntity = false;
    var navElement = document.getElementById('nav_' + loadAreaId);
     if (navElement == null) {
          navElement = document.getElementById('nav' + loadAreaId);
          isNativeEntity = true;
     }

     if (navElement != null)    {
        navElement.onclick = function LoadAreaOverride()        {
            // Call the original CRM method to launch the navigation link and create area iFrame
            if (isNativeEntity)
            {
                 loadArea('area' + loadAreaId);
                 HideViewButtons(document.getElementById('area' + loadAreaId + 'Frame'), buttonTitles);
            }
            else
            {
                 loadArea(loadAreaId);
                 HideViewButtons(document.getElementById(loadAreaId + 'Frame'), buttonTitles);
            }
        }
    }
}

Pedro Beltrão
Portugal Pedro Beltrão said:

Hey David Murdock,

I had the same problem you did, and I came out with a solution:

var IFRAME = document.getElementById('IFRAME_XXX');
    IFRAME.onreadystatechange =
        function onReadyChange()
        {
            if (IFRAME.readyState=="complete")
            {          
                IFRAME.contentWindow.document.getElementById('_BUTTON_I_WANT_TO_REMOVE').outerHTML = "";                
            }
        }

You can change the button part to find button by title instead of going directly by ID.

David Murdock
Canada David Murdock said:

Pedro,

Thanks so much for the solution. I'll be attempting to deploy it this week sometime, so i'll post some feedback then too.

Thanks Again,
Dave

David Murdock
Canada David Murdock said:

Pedro,

I've looked at this, and being a total newb to this type of thing, I'm having a hard time figuring how this all goes together.
I understand that I must pass something to identify the IFRAME that contains the buttons i want to remove and also something to identify the individual buttons to David's function: HideViewButtons.
Then the function changes the visibility state of the buttons to "none" prior to rendering in the browser.

I see how the HideViewButtons Function operates, but i still don't really understand where i'm getting the Iframe variable from.

Well I'll think about it overnight and perhaps it will swim into focus.

Thanks for the help you've already provided, it is appreciated.

Cheers,
Dave

Pedro Beltrão
Portugal Pedro Beltrão said:

Hey David,

Imagine your IFrame is called IFRAME_iInterests that shows your navbar item inside it (I think you've already done so, if you didn't you can search for "CRM navbar item in IFrame".

Now, you want to remove the Add Existing XXX button from the IFrame (this blog explains how you remove it from the Nav bar Menu).

I think to this point, we have your scenario (right?).

Imagine that the button id (you can get it either by viewing the source or using IE Dev Toolbar), is '_MBtoplocAssocOneToMany10001newcontactnewinterest'.

Then your code would be:

var IFRAME = document.getElementById('IFRAME_iInterests');
IFRAME.onreadystatechange =
function onReadyChange()
{
if (IFRAME.readyState=="complete")
{
IFRAME.contentWindow.document.getElementById('_MBtoplocAssocOneToMany10001newcontactnewinterest').outerHTML = "";
}
}

You can adapt this code, to use tooltip (like the one in the blog), instead of ID.

Melayu Boleh
United States Melayu Boleh said:

thank for the info

David Murdock
Canada David Murdock said:

Dave and Pedro,

My profound thanks for your assistance. A perfect solution and some education for me to boot.

If either of you find yourselves in Toronto, Canada, beer's on me!

Cheers,
Dave

dave(at)ironisland.ca

davehawes
United Kingdom davehawes said:

Tong hmmmm beeeer. Thanks Dave, if I'm ever out that way I will be taking you up on the offer!

Alberto
Spain Alberto said:

Hi Dave
I have a trouble near like this. I do not speak english good, so I hope i can explain and understand correctly and not to disturb you too much.
I have a trouble. I want to hide the delete button from the associated view of a custom entity. First I think your code was my salvation, i only have to change "Add existing..." by "x" (delete). But I can not be able to make that this code runs well.

I do no Know if the problem is that it's not possible to make this or that I can undertand what i have to do because my poor english.

As I do not Know explain it well in english I'm going to try to explain with an example.
I have an invoice with diferent invoice's lines. While the invoice is "open" I can create or delete invoice lines. But when the customer pays the invoice I can not delete / insert new lines. I can not disable this record because I have to get data and (is several cases modify the data of the lines, but never delete the line).

I hoped that i could hide the delete button (this solution is enough for me), Is this possible for me?

Please help me, I am desperate.

Thanks!!

davehawes
United Kingdom davehawes said:

Hi Alberto,

To hide a button the script is looking for the words in the tooltip. So if you change the words from:

'Add existing Survey to this record'

to

'Delete'

This should work. I hope that helps.

Marlen
Marlen said:

Hi Dave,
I do have problems getting the script to work properly. Its just simply not firing when I click on the navigation item on the left side to open an associated view. Are there any things beside Title and Data Area DIV Id in need to take into consideration?

Many Thanks,
Marlen

davehawes
United Kingdom davehawes said:

Hi Marlen,

You have been the second person in just a few weeks who has contacted me with this problem. It is because you are trying to manipulate the Opportunity entity which is not a custom entity so has a different naming convention for the iFrames. Please find attached an updated script that should work in the case you emailed me with:

HideStandardAssociatedViewButtons('Opps', ['Add a new Opportunity to this record']);

function HideStandardAssociatedViewButtons(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('area' + loadAreaId);
            HideViewButtons(document.getElementById('area' + loadAreaId + 'Frame'), buttonTitles);
        }
    }
}

Ashish
India Ashish said:

Hi Dave,
I had a query regarding the lookupmulti dialog that is displayed when one clicks the "Add Associated records" button. Is there a way to increase the number of records that can be added from this lookup dialog. An information is displayed on the top of the lookup stating - "More than 100 records are available. Try another entry if you don't find the record you are looking for."
The PagingLimit value in the UserSettings table does not cater to this list, and only modifies the limit for all grid views.
Thanks in advance for your help.
Regards,
Ashish

davehawes
United Kingdom davehawes said:

Hi Ashish,

I don't know any way to customsie that screen. You would probably have to create a custom page and use the API to do this for you.

You might also consider if you are using the right tool for the job. Why do you need to add more that 100 existing records to an entity. Is this for data loading purposes? If you look at your problem again and see if there is a different approach that could solve the it for you.

erdoğan
Turkey erdoğan said:

thanks davehawes your code was fixed my problem ..

Matt
United States Matt said:

I have used this several times in the past very successfully; however, I did run across an overall performance issue with the approach.

After adding the code to the Account entity, we started to notice during testing that the Form was freezing during the load. It seemed to happen 3 out of 5 times. Basically the code loops through to confirm the child entities have completly loaded in order to properly hide the buttons. With multiple requests to hide these buttons started causing serious performance issues when opening the form.

I will admit that we were hiding a larger number of "Add Existing" buttons (about 8). (2 or 3 seem to be fine though)

Is there any other suggestions to make the script run more efficiently, or implement a method that doesn't affect Form Onload?

davehawes
United Kingdom davehawes said:

Hi Matt,

I'm afraid that I do not have any ideas on how to make this code run differently. It took a long time to figure out how to do it at all! Unfortuately I think you have to check the page has loaded fully otherwise the button might not be available to hide at all, and with 8 associated views this could take a little time.

If anyone else has any suggestions I would love to hear them!

SP
South Africa SP said:

Hi Dave,

How can I hide the new button using the same approach. The loadareaid for the new button seem to be the GUID for the parent entity.

Charith
United States Charith said:

Hi Guys,

Thanks for the tip to hide the existing buttons from the forms. I used the javascripts give here and it worked fine for me. But i needed to do this for the whole CRM and it should be generic. I used an external javascript with the methods mentioned above.

But for the CRM Page load i wrote a javascript to catch all the areas. the only problem was with the accounts area where you can add existing account. For this i had to write a specific method. I have pasted below the javascript. it's bit lengthy. As i said before i put all the javascript to an external file i calls this JS file from the onload event of the form. It's unsuppored, but worked fine for me for now.

Anyways thanks to all the guys who published comments and the original poster dave.



var navGroup= document.getElementById('crmNavBar');
if (navGroup != null)
{
var x= navGroup.getElementsByTagName('li');
if (x != null)
{
for( var i = 2; i < x.length ; i++ )
{  
var Div = x[i].innerHTML;
var T = Div.indexOf('id');
var T2 = Div.indexOf('class');
var Title = (Div.substring(T+3,T2));

if (Title.indexOf('nav_') !=-1)
{
  Title = Title.substr(4,Title.length-5);
}
else if (Title.indexOf('nav') !=-1)
{
  Title = Title.substr(3,Title.length-4);
}


if (Title.toLowerCase()  != 'subact')
{
  HideAssociatedViewButtons2(Title);
}
else
{

  HideAssociatedViewButtons('SubAccts', ['Add existing Member to this record']);
  
}

}
}
}


function HideAssociatedViewButtons2(loadAreaId)
{

var isNativeEntity = false;
var navElement = document.getElementById('nav_' + loadAreaId);

if (navElement == null) {
navElement = document.getElementById('nav' + loadAreaId);
isNativeEntity = true;
}



if (navElement != null) {
navElement.onclick = function LoadAreaOverride()
{
if (isNativeEntity)
{
  loadArea('area' + loadAreaId);
  HideViewButtons2(document.getElementById('area' + loadAreaId + 'Frame'));
}
else
{
  loadArea(loadAreaId);
  HideViewButtons2(document.getElementById(loadAreaId + 'Frame'));
}
}
}
}



function HideViewButtons2(Iframe)
{


    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 i = 0; i < liElements.length; i++) {
                        if (liElements[i].getAttribute('title').indexOf('Add existing') !=-1){
                            liElements[i].style.display = 'none';
                            break;
                        }
                    }
            }
        }
    }
}


function HideAssociatedViewButtons(loadAreaId, buttonTitles)
{

var navElement = document.getElementById('navSubAct');
navElement.onclick = function LoadAreaOverride()
{
loadArea('area' + loadAreaId);
HideViewButtons(document.getElementById('area' + loadAreaId + 'Frame'), ['Add existing Member to this record']);
}

}



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').indexOf('Add existing') !=-1)
      {
                          liElements[i].style.display = 'none';
        liElements[i].style.visibility = 'hidden';
                            break;
                        }
                    }
                }
            }
        }
    }
}






KV
India KV said:

Dave,

this is what I am exactly looking for but somehow its not working

code i am using is as following

function HideAssociatedViewButtons(loadAreaId, buttonTitles)
{
var navElement = document.getElementById('nav_' + loadAreaId);

if (navElement != null)
{
navElement.onclick = function LoadAreaOverride()
{
loadArea(loadAreaId);
HideViewButtons(document.getElementById(loadAreaId + 'Frame'),
buttonTitles);
}
}
}

function HideViewButtons(Iframe, buttonTitles) {
alert(Iframe);
    if (Iframe != null) {
        Iframe.onreadystatechange = function HideTitledButtons() {
  alert(Iframe.readyState);
              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;
                        }
                    }
                }
            }
        }
    }
}



HideAssociatedViewButtons('tc_tc_xx_tc_xx11value', 'Add existing xx xx1 Value to this record');

In your code example txt file you calling it twice and in different fashion.

the problem with above code it doesn't fire completely what I mean is that alert statement which I have added   alert(Iframe.readyState); is not fired, though alert(Iframe); does.

am I using your code in wrong way?

Balaji
India Balaji said:

Hi Dave,

Wondeful !!!!...No words to desribe you..I have been trying, I donot know how long to get something like this working. You just did the magic. Great!! .I am more a Dynamics ERP guy than a CRM guy, still for anyone coming over from ERP to CRM becomes more and more easier with the prescence of great minds like you. Once again, sincere thanks

Regards
Balaji

Simon
United Kingdom Simon said:

Hi,

I've used this code very successfully in the past. However I'm trying to adapt it so that I can simply change the button title rather than hide it. I've tried to simply call:         liElements[i].title = '12321'; - if i check out an 'alert' call the text is set but the button text doesn't change. Any thoughts?

I was also wondering what the line: ' Iframe.onreadystatechange = function HideTitledButtons() '
does - is the function 'HideTitledButtons()' a built in CRM function?

Thanks,
Simon

davehawes
United Kingdom davehawes said:

Hi Simon, changing the title will only change the tooltip in CRM. You will have to dig a little deeper in the DOM to get the element with the text. Unfortuately I don't have an installation to play with at the moment to work it out.

KV - I suspect that the second alert box isn't firing because the script has not managed to find the iFrame. Is the first alert box saying 'undefined' by any chance?

Just a quick note - if you want to ask a question then I am on twitter @davehawes which I check a lot more than the comments here!

mike
United States mike said:

My requirement is hiding these buttons (Add New and Existing) on a related custom entity from Accounts parent form. Your code works fine and thanks for sharing the code. My another requirement is after clicking the custom related entity from left hand side navigation, I directly want to open a new record from within the parent form if there are no records exist. If there is an existing record I want to open the existing record directly from the Accounts parent form. (I am enforcing a 1 to 1 relationship). Thanks in advance.

Auto Transport
United States Auto Transport said:

It is, however, becoming more and more common for the shipper to offer cars directly towards the house from the buyer. You will find out the location where the driver is, and when things are on schedule. Suppose a national average cost per gallon of gas of $3.

My webpage ...  Auto Transport - nmlist.com/.../...-car-shipping-systems-118233.htm

teeth whitening products
United States teeth whitening products said:

Just swish it around your mouth for a couple of minutes, or you can mix it with a teaspoon of baking soda and a dash of salt to make a teeth whitening paste you can apply on your teeth. Whatever is the problem, these products and systems have solutions for it. On a yearly basis hundreds and hundreds if not lots of people teeth whitening mix to waste in excess of $10 billion with makeup teeth whitening techniques.

Feel free to visit my weblog ::  teeth whitening products - www.pinkymckay.com/.../

WordPress Expert
United States WordPress Expert said:

These are actually enormous ideas in regarding blogging. You have touched some fastidious things here. Any way keep up wrinting.

Have a look at my weblog -  WordPress Expert - http://www.sorayasfinearts.com/?attachment_id=198

certified internet marketing consultant vancouver
United States certified internet marketing consultant vancouver said:

Hello There. I found your blog using msn. That is a very smartly written article. I'll be sure to bookmark it and return to learn more of your useful info. Thanks for the post. I'll certainly return.

Look at my web page -  certified internet marketing consultant vancouver - www.pagerankkontrol.com/...ralinternetservices.com

SW Florida WordPress Expert
United States SW Florida WordPress Expert said:

Heya i am for the first time here. I found this board and I find It really useful & it helped me out much. I hope to give something back and aid others like you helped me.

Here is my weblog ...  SW Florida WordPress Expert - utchy.s3.xrea.com/item/190/catid/6?memberid=1

MS CRM Customization
MS CRM Customization said:

Hide associated view buttons

Some time user is not required some buttons to be shown in associated view grid menu. To hide associated

Landrecs - Online Real Estate Education
United States Landrecs - Online Real Estate Education said:

Hi it's me, I am also visiting this web site regularly, this site is in fact good and the people are actually sharing fastidious thoughts.

Comments are closed