1

my aim is to add a Ribbon Button which is opening a printing dialog for a selected file in a document library. I already added the Button with SP Designer and linked it with a html file which is calling the js.

The function printFile is called by the Ribbon.

function printFile() {
    try{
        //throws error
        ExecuteOrDelayUntilScriptLoaded(start, "sp.js");
    }catch(e){
        alert(e.message);
    }
}

function start() {
    var ctx = SP.ClientContext.get_current();
    var items = SP.ListOperation.Selection.getSelectedItems(ctx);
    var selectedItem = '';
    var itemURL;
    for (index in items) {
        //only for testing
        alert(items[index].id);
        alert(items[index].displayName);
        printDocument(items[index].file);
    }
}

When running i got this error:

The value of the property "ExecuteOrDelayUntilScriptLoaded" is null or undefined, not a Function object

Any idea to solve this error?

1

Change

ExecuteOrDelayUntilScriptLoaded(start, "sp.js");

with

SP.SOD.executeOrDelayUntilScriptLoaded(start, "sp.js");

Reference: http://msdn.microsoft.com/en-us/library/ff411788(v=office.14).aspx

  • also an error: "SP is undefined" – mbauer May 7 '13 at 6:50
  • is this document library web part on some custom application page ? it is obvious that you have issue with reference to sp.js ... core sharepoint Javascript client object model cannot be called from .html page if this is what you are trying .. for anything else you would have to write custom web service .. try adding this .. <script type="text/ecmascript" src="/_layouts/SP.Core.js"></script> – displayName May 7 '13 at 7:15
  • didn't work. it is a standard document library on a site. is there another way to access the sp.js. i only have visual studio 2012 web express and no direct access on the sp server. – mbauer May 7 '13 at 7:42
  • 1
    sp.js should be loaded by default in SP2010. So you do probably not need the ExecuteOrDelay there, since its executed when a user clicks it. By then everything should be loaded – Anders Aune May 7 '13 at 7:52
  • you should describe all the steps you took .. where you put this code .. i tried your code and it works .. – displayName May 7 '13 at 8:45
0

can you please try This link .

Please update if working as I am also facing same challenge.
My developement: using VS 2010 add ribbon button as a feature and call Javascript. refer This Link

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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