locked
Refresh list after insert to another table RRS feed

  • Question

  • HTML Client

    I'm still using a command table to execute some inserts on the server.  I'm inserting a record that is creating additional records.  I want to refresh my list to see the new records but it's not working.  This is probably simple but I seem to be missing something.

    Here's my button execute code:

    myapp.ScheduleView.CreateAssignments_execute = function (screen) {
        // Write code here.
        msls.showMessageBox("Are you sure you want to create the assignments?", {
            title: "Create Assignments",
            buttons: msls.MessageBoxButtons.yesNo
        }).then(function (result) {
            if (result === msls.MessageBoxResult.yes) {
                var backgroundProcess = myapp.activeDataWorkspace.ApplicationData.BackgroundProcesses.addNew();
                backgroundProcess.setSchedule(screen.Schedule);
                backgroundProcess.Type = "Create Assignments";
                return myapp.activeDataWorkspace.ApplicationData.saveChanges(
                    function () {
                        screen.AssignmentsByScheduleId.load();
                    });
            }
            else (result === msls.MessageBoxResult.no); {
                screen.closePopup;
            }
        });
    };
    Thanks for any feedback.


    Brian

    Thursday, April 18, 2013 7:22 PM

Answers

  • Hi Brian,

    saveChanges() method will return a Promise object, then you can add your complete handler to that Promise object. So looks like the code should be

                return myapp.activeDataWorkspace.ApplicationData
                    .saveChanges().then(function () {
                        screen.AssignmentsByScheduleId.load();
                    });
    

    Best regards,
    Huy Nguyen

    • Marked as answer by Brian Kidd Monday, April 22, 2013 11:23 PM
    Monday, April 22, 2013 5:31 PM

All replies

  • Brian:

    How about screen.AssignmentsByScheduleId.Refresh();

    instead of screen.AssignmentsByScheduleId.load();

    Mark

    Thursday, April 18, 2013 10:57 PM
  • Mark,

    Thanks for the suggestion.  That will work with the Silverlight client but in this case, the HTML client using javascript will not.

    Thank you,

    Brian


    Brian

    Sunday, April 21, 2013 8:22 PM
  • Hi Brian,

    saveChanges() method will return a Promise object, then you can add your complete handler to that Promise object. So looks like the code should be

                return myapp.activeDataWorkspace.ApplicationData
                    .saveChanges().then(function () {
                        screen.AssignmentsByScheduleId.load();
                    });
    

    Best regards,
    Huy Nguyen

    • Marked as answer by Brian Kidd Monday, April 22, 2013 11:23 PM
    Monday, April 22, 2013 5:31 PM
  • Thanks Huy, that worked.

    Brian


    Brian

    Monday, April 22, 2013 11:24 PM