Forums/Community/Community questions & answers

Answered

Hiding Report Tab Using Javascript

William Kirby
asked this on October 19, 2009 04:06

Hello,

We have a need to hide the "Reports" tab from view, and Zendesk support said that we would need to use Javascript to do so. Is there anyone that has come across this problem and can help us solve it? My problem specifically is that there do not seem to be any associated ID or NAME tags to use in scripting?

Any help would be most appreciated.

 

Comments

User photo
Jake Holman
Product Manager

Hi there,

Are you trying to hide it from all users or just from Agents?

Jake Holman
Zendesk Support

October 21, 2009 03:59
User photo
William Kirby
netcrowd

Thanks for the reply.

We are trying to hide from everyone, as it's a feature we don't use. We have an agent who is only able to view members of a certain group but the reports section allows them access to statistics from the entire account.

October 21, 2009 04:07
User photo
Jake Holman
Product Manager

Hey William,

Try adding this code to a Global JavaScript Widget: http://www.pastie.org/663316

I've not tested it extensively, but it should work fine :)

Jake Holman
Zendesk Support

October 21, 2009 04:33
User photo
William Kirby
netcrowd

Jake,

Many thanks for that, works a treat!!!

Will

October 21, 2009 04:41
User photo
Jayesh Patel

Hey guys, I have no javascript experience.  How would that script be changed if I'm just trying to remove the "submit a ticket" option, but keep the "check on my ticket status" option?  I want to direct my users to use a dropbox that asks specific questions based on closest forum topic.  Thanks.

November 01, 2009 21:28
User photo
Jake Holman
Product Manager

@Jayesh: Replace the /reports with /requests/portal/new - this shouldn't prevent you from creating new tickets (at least I hope not).

Jake Holman
Zendesk Support

 

November 03, 2009 07:30
User photo
Jayesh Patel

Thanks.  Also, you need to code for anonymous user, so my widget looks like:

 

Event.observe(window, 'load', function() { $$('a[href="/requests/anonymous/new"]').each(function (e) { Element.hide(e.parentNode); }); }); Event.observe(window, 'load', function() { $$('a[href="/requests/portal/new"]').each(function (e) { Element.hide(e.parentNode); }); });

November 03, 2009 08:26
User photo
ReeseMcBlox
roblox

I used Jayesh's code on Friday to solve my concern (email only help desk) but now tonight it's not working anymore. I checked on firefox and IE. Did something change?

March 29, 2010 00:16
User photo
Colin Murphy
singlefeed

Yes, the JavaScript widgets we were using to hide the "Submit a Request" and "Check Existing Requests" broke recently... I assume with the Zendesk release this past weekend.  After a bit of fiddling, I have been able to "re-hide" all tabs for agents and logged in users.  For anonymous users, I have been able to hide the "Submit a Request" tab with this code:

 

Event.observe(window, 'load', function() {
    $('a[href="/anonymous_requests/new"]').each(function (e) { Element.hide(e.parentNode); });
});

Event.observe(window, 'load', function() {    $('a[href="/anonymous_requests/new"]').each(function (e) { Element.hide(e.parentNode); });});

However, I can't figure out code to hide the "Check Existing Requests" tab for anonymous users.  For reference, here is the code that removes existing requests for logged in users and agents:

Event.observe(window, 'load', function() { $$('a[href="/requests"]').each(function (e) { Element.hide(e.parentNode); });});

 

April 01, 2010 10:24
User photo
Colin Murphy
singlefeed

darn it... i can't edit my comment to remove the typo :(

April 01, 2010 10:26
User photo
Colin Murphy
singlefeed

OK, this successfully removed the "check existing requests" for anonymous users (note that it contains our specific zendesk url so it will need to be modified for general consumption):

Event.observe(window, 'load', function() { $('a[href="/login?return_to=http%3A%2F%2Fsinglefeed.zendesk.com%2Frequests"]').each(function (e) { Element.hide(e.parentNode); }); 

April 01, 2010 10:40
User photo
Mark Pengelski
line2

Hello Colin & Jake : We'd like to create a widget that allows us to do the following:

1. Hide the Submit a New Request from the top nav on any page

Can you all help? It seems to be what you are doing? We're only temporarily looking to hide ticket creation, which we recognize is a  strange while using ZenDesk.

Thanks!

Mark

April 05, 2010 21:58
User photo
Skip Moore
Zendesk
Check Answer
Event.observe(window, 'load', function() {
if ($('#top-menu #green .tab_new')[0]){
   $('#top-menu #green .tab_new')[0].hide('<a href="/requests/portal/new" class="tab">Ask A Question</a>')
if ($('#top-menu #green .tab_requests')[0]){
Event.observe(window, 'load', function() { if ($$('#top-menu #green .tab_new')[0]){ $$('#top-menu #green .tab_new')[0].hide('<a href="/requests/portal/new" class="tab">Ask A Question</a>'); } if ($$('#top-menu #green .tab_requests')[0]){ $$('#top-menu #green .tab_requests')[0].hide('<a href="/requests" class="tab">what ever you want</a>'); }});
   $('#top-menu #green .tab_requests')[0].update('<a href="/requests" class="tab">what ever you want</a>')
}
May 06, 2010 06:36
User photo
Nancy-Ellen Martin
turbosquid

I'm currently trying to hide these same tabs from my page and I tried using this code

Event.observe(window, 'load', function() {
if ($('#top-menu #green .tab_new')[0]){   $('#top-menu #green .tab_new')[0].hide('<a href="/requests/portal/new" class="tab">.</a>');}

if ($('#top-menu #green .tab_requests')[0]){   $('#top-menu #green .tab_requests')[0].update('<a href="/requests" class="tab">..</a>');}
});

The widget is not working, and my firefox error console reads, "$('#top-menu #green .tab_new') is null.

Does anyone have any ideas or suggestions as to what my problem could be?

May 17, 2010 10:55
User photo
Skip Moore
Zendesk

Hi Nancy,

I took a look at your code and updated it. I have also updated the answer on this topic. Thanks for letting us know.

Skip
Zendesk Support 

May 17, 2010 11:36
User photo
Nancy-Ellen Martin
turbosquid

Thanks for the help Skip, that worked!

May 17, 2010 11:57
User photo
Nancy-Ellen Martin
turbosquid

Would you or anyone else also happen to have the code to remove the first two tabs on the bar and the bar itself? I would like to collapse the whole bar, if possible

May 18, 2010 07:10
User photo
Greg

Skip,

I tried your code, which successfully hides the "Submit a Request" and "Check Your Existing Requests". However, it doesn't add the replacement links, "Ask a Question" or "whatever you want". 

 

I'm pretty much Javascript illiterate, and help you can give is much appreciated.

June 17, 2010 12:50
User photo
Piotr Pilakowski

OK, so code which hide reports tab from all users works fine. I'm not very familiar with Java so I would like to ask is there a way to hide a reports tab from agents? I would like my reports to be visible only to admins.

 

Thanks in advance

Piotr

June 23, 2010 01:54
User photo
Shaun

Hi I would like to remove "check your existing requests" tab globally for all user types. How can i do this? I tried using collin's suggestion in a global javascript widget but not working

 

Event.observe(window, 'load', function() { $('a[href="/login?return_to=http%3A%2F%2Fasiaclassified.zendesk.com%2Frequests"]').each(function (e) { Element.hide(e.parentNode); });

November 04, 2010 02:20
User photo
Jon Namnath
marinsoftware

For global use, seemed easiest to just use CSS. Plus, there's no jilting on page load:

#green .tab_requests,
#green .tab_new {
    display: none;
}

May 11, 2011 10:24
User photo
Marci

I tried using the CSS solution above to hide the "Home" tab....but it also hides the "check my existing requests" tab for logged in users!

 

My CSS reads as follows:

 

#green .tab_requests,
#green .tab_new {
    display: none;
}

 

Any thoughts?

June 30, 2011 22:44
User photo
Marci

I ended up using javascript after all....

 


Event.observe(window, 'load', function() { $$('a[href="/home"]').each(function (e) { Element.hide(e.parentNode); }); }); Event.observe(window, 'load', function() { $$('a[href="/home"]').each(function (e) { Element.hide(e.parentNode); }); });

 

Worked like a charm! (but I think I've got some overkill code here....corrections welcomed)

June 30, 2011 23:27
User photo
Andrew Moyer

We'd like the ability to hide "submit a request" to specific users.  These users would be part of an organization that is tagged as "free users" and they would be able to post/reply/comment on forums but not submit support requests. 

 

How would I modify the javascript to hide it for a specific organization and subsequent users? (this is a big deal for us so thank you for any help you can relay!)

November 28, 2011 19:03
User photo
Max McCal
Product Manager

Hi, Andrew -

I can't say for sure, but it seems to me it would be a little more difficult to hide this tab from just one organization. If you hid it from just that one organization, it would still be visible to users who are not logged in at all, and if you're using org as your method for hiding this, since users who aren't logged in have no organization. I think there might be some better options, so I sent you a ticket so we can discuss. Thanks!

November 30, 2011 14:57
User photo
Duke Adamonis
nuodb

@Max - I am looking to implement the same functionality that Andrew had mentioned above with respect to "free users". Was there ever any conclusion to this? 

July 23, 2012 09:43
User photo
Max McCal
Product Manager

Hi, Duke -

Same answer, essentially. If you're looking to hide the tab, you can hide it from everyone using Javascript, but hiding it from just one organization is challenging because it will still remain visible to people who are not logged in. There is a much more in depth discussion of hiding and showing tabs based on a user's org here: https://support.zendesk.com/entries/175801-show-or-hide-tabs-based-...

July 24, 2012 15:28
User photo
chris
plexustechnology

The above Javascript solution worked to hide the "home tab, but because the script is loading last, I still see the tab there for a second before it dissapears.  Is there any way to globally remove the home tab but not have it flash like it currently is?

 

Thanks

July 18, 2013 16:45
User photo
Jake Holman
Product Manager

@Chris: You could go down the CSS route instead. Add this to a CSS widget and you shouldn't see the flashing:

#top-menu .tab_home { display: none; }
July 18, 2013 17:14
User photo
chris
plexustechnology

Thanks Jake!  I had added just  .tab_home { display: none; }  which didnt work... thanks for pointing out the correct selector to use, much appreciated.

 

July 18, 2013 17:19