locked
Please expose msls.sharepoint, please RRS feed

  • General discussion

  • I will keep this short until I get time to list the many ways this would be beneficial to CBApp dev.

    Please expose the msls.sharepoint object. 

    There's a lot of handy properties methods and functions in there and I hate to edit msls.js.

    Not the least of which is the cross-site request executor which is difficult and wasteful to have to duplicate in order to make calls to SP API.

    TIA,

    Josh



    • Edited by joshbooker Tuesday, March 18, 2014 11:29 PM
    Tuesday, March 18, 2014 11:27 PM

All replies

  • Josh, could you provide us with your scenario or some explanation so that we can analysis this issue on our side?


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 20, 2014 7:17 AM
  • Interacting with SharePoint from javascript in HTML Client requires loading the SP CSOM scripts, referring to the AppWebUrl and HostWebUrl, and for HostWeb Calls - the cross-site request executor is needed.

    All these operations are happening in msls.js and are nicely built into the msls.sharepoint object, however that object is contained in an anonymous self-executing function and it is not exposed via msls.expose().

    Therefore the msls.sharepoint object cannot be used in custom code at runtime without altering msls.js

    Like so:

        msls_sharepoint = {
            hostUrl: hostUrl,
            appWebUrl: appWebUrl,
            serverUrl: serverUrl,
            chromeBackgroundColor: chromeBackgroundColor,
            chromeLinkFontColor: chromeLinkFontColor,
            sharePointImagesUrl: sharePointImagesUrl,
            context: null,
            hostWeb: null,
            appWeb: null,
            executor: null,
            ready: promise.then,
            process: function () {
                var me = this, context = me.context, deferred;
                if (!queryPromise) {
                    deferred = $.Deferred();
                    queryPromise = deferred.promise();
                    msls_dispatch(function () {
                        context.executeQueryAsync(
                            function () { deferred.resolve(); },
                            function (error) { deferred.reject(error); }
                        );
                        queryPromise = null;
                    });
                }
                return queryPromise;
            },
            load: function () {
                var me = this, context = me.context, deferred = $.Deferred(),
                    args = Array.prototype.slice.call(arguments, 0);
                args.forEach(function (o) {
                    context.load(o);
                });
                return me.process();
            },
            openDocument: openDocument,
            getFileIconUrl: getFileIconUrl,
            getDefaultFileIcon: getDefaultFileIcon,
            getFileExtension: getFileExtension
        };
        //Custom: expose msls.sharepoint
        msls_expose("sharepoint", msls_sharepoint);

    If it were exposed, then we wouldn't have to duplicate the above requirements when do scenarios such as:

    Create or alter lists; Check for existence of an item; upload documents; check group membership; query items in order to... let's say, populate a choice list; anything else that requires a call to sharepoint.

    CBA is THE RAD tool for sharepoint apps yet many LS devs haven't yet fully dug into the SP REST API.  It only makes sense to expose the msls.sharepoint REST executor so we don't have to deal with the requirements - we can just post a request using the familiar promise operation.

    Another benefit is, if the object were exposed, we could extend it.  Devs could build all sorts of useful new reusable methods and append them to the msls.sharepoint object while avoiding any changes to msls.js. 

    Buy the way, this goes for any of the msls objects and methods.  For example, anyone want to create controls in the msls.ui.controls namespace?  Can't - it's not exposed.

    I'll try to find time to put this request on uservoice.

    Thanks for listening.

    Josh


    • Edited by joshbooker Thursday, March 20, 2014 1:50 PM
    Thursday, March 20, 2014 11:31 AM
  • @Angie

    Why has Josh received no reply to his request, even if the answer is "it's just not going to happen"? He's even gone to the trouble of creating a User Voice suggestion (as we're so often asked to do), but when I check that, I notice that it has also not received any reply from Microsoft (or Contingent staff such as yourself).

    You asked for his "scenario, or expalnation" back in March, yet when I found this post today (May 7) there has been nothing in return from your end. Why ask for something & then just leave the issue to languish with no update at all.

    Josh went to the trouble of giving you the detailed use case you asked for, surely he at least deserves a reply?

    If the answer does happen to be that the team has decided that "it's not going to happen", for goodness sake give the poor guy an answer, preferably with an reason as to why. 


    Yann Duran
         - Co-Author of Pro Visual Studio LightSwitch 2011
         - Author of the  LightSwitch Central Blog

    FREE Download: Luminous Tools for LightSwitch
    (a Visual Studio productivity extension for LightSwitch)
     
    Click Mark as Answer, if someone's reply answers your question
    Click  Vote as Helpful, if someone's reply is helpful
     
    By doing this you'll help everyone find answers faster.

    Wednesday, May 7, 2014 6:45 AM
    Moderator
  • HI Yann,

    Thanks for your response.

    As we know, the Uservoice site is for suggestions and ideas, what you would like to see in future versions of the Visual Studio suite of products, Visual Studio team and Lightswitch development team look into the issue according to the proof customers provide. As we see, Beth often joins in the discussion, and Contingent staff collect some information from customers.

    We could give votes for this issue, VS team will give more attention to it. At the same time I will also try to consult with LightSwitch development team members. Thanks for your understanding.

    Best regards

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 7, 2014 7:24 AM