0

I am developing a Office 365 Mail Addin in Napa. I am trying to use the object of SP.ClientContext but it shows me error that SP is not defined.

Office.initialize = function (reason) {
    $(document).ready(function () {
        app.initialize();

        var context = new SP.ClientContext("https://mysite.sharepoint.com/"); // <-- Error
        var web = context.get_web();
    });
};

I would like to know can SharePoint objects like SP.ClientContext, SP.Web, etc. be used while developing Office 365 Mail Addin in Napa? If yes, then what is the best approach for the same?

Update 7 Aug 2015:

The Napa editor for the code SP.SOD.executeFunc('sp.js', 'SP.ClientContext', Office.initialize); shows error as

'SP' is not defined

Screenshot of error in Napa editor

While executing the code in the Google Chrome's console I see the error

Uncaught ReferenceError: SP is not defined

Screenshot of error in Google Chrome console

The conclusion I arrive at here is that - the SharePoint file sp.js is simply not available to Office Mail Addin. For this I probably need to download sp.js and upload in my Main Addin which would be quite inefficient. Is there any way to reference sp.js of Office 365 in Office Mail Addin? For a SharePoint app the path is /_layouts/15/sp.js. So what would be the path for Office Mail Addin?

0

Yes, we can use it in Napa while developing the app, if it is not getting reference of sp.js from sharepoint itself you can add external sharepoint api.

<script src='//cdn.jsdelivr.net/sharepointplus/3.0.10/sharepointplus.min.js' type='text/javascript'></script>
  • The library you referring in your answer is SharepointPlus and not SharePoint's sp.js which resides in /_layouts/15/sp.js. That is the file in need to refer to. The API calls of SharepointPlus is completely different from sp.js – Naveen Aug 7 '15 at 11:34
  • I understand it is different but it will resolve your problem just take a try. – Shivendra Patel Aug 7 '15 at 11:40

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.