LightSwitch 2013 - Add/Edit Screens. RRS feed

  • Question

  • Hey,

    I'm building a LightSwitch 2013 HTML application.

    On my Add/Edit screens i'v added an exit button that navigate to the previous screen (by doing myapp.cancelChanges();).

    I want to show the user a message "Are you sure that you want to exit? changes won't be saved." when he clicked on the exit button. But i want to show him that message only if he made changes, otherwise he didn't change nothing and he doesn't needed to be asked that question.

    Any ideas?


    Wednesday, March 2, 2016 6:57 AM


  • Hi Yaron,

    here is some sample code for entity 'Student' and a button action 'Cancel'.

    myapp.AddEditStudent.Cancel_canExecute = function (screen) {
        return myapp.activeDataWorkspace.details.hasChanges;
    myapp.AddEditStudent.Cancel_execute = function (screen) {
        if (myapp.activeDataWorkspace.details.hasChanges) {
            msls.showMessageBox("Cancel changes?", {
                    title: "Do you want to cancel the changes",
                    buttons: msls.MessageBoxButtons.yesNo,
                    defaultResult: msls.MessageBoxResult.yes })
                .then(function (result) {
                    if (result === msls.MessageBoxResult.yes) {
        } else {



    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 Wednesday, March 16, 2016 1:52 AM
    Thursday, March 3, 2016 9:52 AM