locked
Lightswitch HTML client URL to edit directly an item RRS feed

  • Question

  • Hello from France,

    I want to display directly the edit form for an entity's item

    These URLs work : 

    http://localhost:34347/HTMLClient/?entity=ApplicationData/Bulletins(2)#/AddEditBulletin/2/[f5f89c8f]

    or http://localhost:34347/HTMLClient/?entity=ApplicationData/Bulletins#/AddEditBulletin/2/[f5f89c8f]

    (entity name : bulletin, id  : 2, edit screen : AddEditBulletin.lsml)

    Is there some documentation about URL for Lightswitch HTML client or somebody have a better way to do that ?

    Thanks

    Friday, January 30, 2015 2:49 PM

Answers

  • We use deep links for example:

    /HTMLClient/#/MasterTranslationsSubsetListDetails/[d7ad06044]

    ?language=FR&name=Budget&text=Budget

    We pass query parameters in and process them in the supporting screen's created event. Then some code...

        var language = getClientParameter("language");
        var name = getClientParameter("name");
        var text = getClientParameter("text");
    
    // code re-utilised from LightSwitch/SharePoint Chrome
        function getUrlParameter(url, parameterName) {
            var pattern = "[\\?&]" + parameterName + "=([^&#]*)",
                regularExpression = new RegExp(pattern),
                results = regularExpression.exec(url);
            return results ? results[1] : null;
        };
    
        function getClientParameter(parameterName) {
            if (!parameterName) return null;
    
            var clientParameterValue = getUrlParameter(window.location.href, parameterName);
            if (clientParameterValue) return clientParameterValue;
    
            return clientParameterValue;
        };
    

    Bonne chance!

    David


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Marked as answer by Angie Xu Monday, February 9, 2015 1:30 AM
    Friday, January 30, 2015 3:37 PM

All replies

  • We use deep links for example:

    /HTMLClient/#/MasterTranslationsSubsetListDetails/[d7ad06044]

    ?language=FR&name=Budget&text=Budget

    We pass query parameters in and process them in the supporting screen's created event. Then some code...

        var language = getClientParameter("language");
        var name = getClientParameter("name");
        var text = getClientParameter("text");
    
    // code re-utilised from LightSwitch/SharePoint Chrome
        function getUrlParameter(url, parameterName) {
            var pattern = "[\\?&]" + parameterName + "=([^&#]*)",
                regularExpression = new RegExp(pattern),
                results = regularExpression.exec(url);
            return results ? results[1] : null;
        };
    
        function getClientParameter(parameterName) {
            if (!parameterName) return null;
    
            var clientParameterValue = getUrlParameter(window.location.href, parameterName);
            if (clientParameterValue) return clientParameterValue;
    
            return clientParameterValue;
        };
    

    Bonne chance!

    David


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Marked as answer by Angie Xu Monday, February 9, 2015 1:30 AM
    Friday, January 30, 2015 3:37 PM
  • This is great! 
    Friday, January 30, 2015 5:36 PM
  • Merci David,

    Ok so this URL also work :

    http://localhost:34347/HTMLClient/#/AddEditBulletin/2/[f5f89c8f]

    I want to send the URL by email.

    But what about last value [f5f89c8f] ? Is it a timestamp ? It seems mandatory ?

    Google is my friend, but I didn't found any help about url construction...


    Friday, January 30, 2015 5:43 PM
  • [hhhhhhhh] is a random string, think it is the id of a page internally so you can go back to it, and jQuery needs something there.

    Cheers

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    Friday, January 30, 2015 6:12 PM