Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am getting the following Javascript error when clicking on the List tab in the SP2010 ribbon for a Project Task list that I have placed into a webpart on the default.aspx page:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3) Timestamp: Tue, 5 Jul 2011 20:32:33 UTC

Message: 'projectTaskButtonAppName' is undefined Line: 1302 Char: 9 Code: 0 URI: http://sptest/_layouts/sp.ribbon.debug.js?rev=lc6eCMZP6gL5LnuSYh0S6Q%3D%3D

I have searched quite extensively and have not found any other complaints..

Does anyone have any idea what I can check? I do not have MS Project on my machine, but surely that wouldn't break the JS.

share|improve this question
    
I will also note that all options are grayed out from this error. But if I click on the webpart checkbox, click on list, click off the webpart, click back on the webpart, then in some cases I the options are no longer grayed out. –  JR_ATLDev Jul 5 '11 at 20:40

6 Answers 6

Try adding a Content Editor webpart and add the code there as given in the first approach -

<script type="text/javascript" language="javascript">
    var elemDivTaskButton = document.createElement('div');
    document.body.appendChild(elemDivTaskButton);

    var projectTaskButtonAppName = (typeof projectTaskButtonAppName === 'undefined') ? elemDivTaskButton : projectTaskButtonAppName; 
</script>
share|improve this answer

I tried to hide 'New link' on List/Library View by set the List View WebPart's Toolbar property to "No Toolbar" and I got this Error. Then I found different approaches listed below.

Before that, please change the required Webpart's Toolbar Property back to "Summary Toolbar".

Approach 1 (Simple)

In common js file, which you used in the site (Or Create New JS file, upload it in Assets Library and give reference in your site Master Page) add the below code. This will simply create a empty div and add it to the page. It Works!

<script type="text/javascript" language="javascript">
    var elemDivTaskButton = document.createElement('div');
    document.body.appendChild(elemDivTaskButton);

    var projectTaskButtonAppName = (typeof projectTaskButtonAppName === 'undefined') ? elemDivTaskButton : projectTaskButtonAppName; 
</script>

Approach 2

  1. Create a HTML file with below code and upload it in SiteAssets Library.
  2. Edit the 'AllItems.aspx' page of the List (or required page where the list view added) and Add a Content Editor WebPart (CEWP).
  3. Edit the Content Editor WebPart and in "Content Link" property (On WebPart properties Panel) specify the above HTML file URL. Click 'Ok'.
  4. In 'Page' tab on Top Ribbon, click "Stop Editing". Now check the Page. The JS Error should be gone.

        //Invoke HideNewItemLinkAndActviateWP Method after PageLoad.
        _spBodyOnLoadFunctionNames.push("HideNewItemLinkAndActviateWP");
    
        function HideNewItemLink()
        {
            try
            {
                HideNewItemLink('Hero-WPQ2');
                SetWebPartActive('MSOZoneCell_WebPartWPQ2');
            }
            catch(err)
            {
                //Handle errors here
            }
        }
    
        function HideNewItemLink(tblId)
        {
            try
            {
                var tblNewItemLink = null;
                tblNewItemLink = document.getElementById(tblId);
                if(tblNewItemLink != null)
                {
                    tblNewItemLink.style.display='none';
                }
            }
            catch(err)
            {
                //Handle errors here
            }
        }
    
        function SetWebPartActive(wpId)
        {
            setTimeout(function() {
                var webPart = document.getElementById(wpId);
                if(webPart != null) {
                    var dummyEvent = new Array();
                    dummyEvent["target"] = webPart; 
                    dummyEvent["srcElement"] = webPart; 
                    WpClick(dummyEvent);
                    }
            }, 200)
        }
    
share|improve this answer

I had the same problem with my project task list. In order to get rid of this problem i tested different web part settings for project task list. The option that worked for me was setting Toolbar type to: Full Toolbar.

share|improve this answer

I've notice this issue occurs when you change the Toolbar.Type from "Standard" to "None" on the XsltListViewWebPart

share|improve this answer

The Ribbon icons are grayed out but still Active/useable. If you click elsewhere, they tend to come back to life with color. Appears to be a SP Bug/scripting error that has a workaround.

share|improve this answer
up vote 0 down vote accepted

I solved the problem by adding a try catch to the JS that was breaking. I made the following change to SP.Ribbon.debug.js: Line 1302-

    try{    
    return !eval($v_0.HiddenScript);
    }
    catch(e){
    return true;
    }

Now the ribbon buttons are at least usable. I think I'll have to make this same change in SP.ribbon.js .

Perhaps this is due to me not having MS Project installed on my box.

Anyway hope this helps some other poor soul as well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.