none
Question regarding LS HTML, navigating to screen populated with the new entity RRS feed

  • Question

  • Hi,

    When I have added a new entity from a screen (add&edit screen) and press save I need to navigate to a screen (detail) and show the new entity.

    How to that with Afterclosed command.

    afterClosed:

    function() {

    myapp.showcustomer(some navigation.....);

    regards

    Sven


    Sven Elm

    Wednesday, April 17, 2013 3:09 PM

Answers

  • Hi Sven,

    Let's say you have 3 screens:
    - BrowseCustomers
    - AddEditCustomer
    - ViewCustomer

    And you want to write a command on BrowseCustomers screen to
    - Add a Customer and navigate to AddEditCustomer.
    - If the user adds a Customer and saves, navigate to ViewCustomer.

    You can add a button called 'AddCustomer' to Browse Customers screen and write the following code:

    myapp.BrowseCustomers.AddCustomer_execute = function (screen) {
        myapp.showAddEditCustomer(null, {
    
            beforeShown: function (addEditScreen) {
                // Create new Customer here so that
                // discard will work.
                var newCustomer = new myapp.Customer();
                addEditScreen.Customer = newCustomer;
            },
    
            afterClosed: function (addEditScreen, navigationAction) {
                // If the user commits the change,
                // show the new Customer in View Screen.
                if (navigationAction === msls.NavigateBackAction.commit) {
                    var newCustomer = addEditScreen.Customer;
                    myapp.showViewCustomer(newCustomer);
                }
            }
    
        });
    };

    Here's a sample application if you're intersted. http://sdrv.ms/11vbpYA

    Best regards,
    Huy Nguyen

    • Marked as answer by Sven Elm Wednesday, April 17, 2013 7:05 PM
    Wednesday, April 17, 2013 4:15 PM

All replies

  • Hi Sven,

    Let's say you have 3 screens:
    - BrowseCustomers
    - AddEditCustomer
    - ViewCustomer

    And you want to write a command on BrowseCustomers screen to
    - Add a Customer and navigate to AddEditCustomer.
    - If the user adds a Customer and saves, navigate to ViewCustomer.

    You can add a button called 'AddCustomer' to Browse Customers screen and write the following code:

    myapp.BrowseCustomers.AddCustomer_execute = function (screen) {
        myapp.showAddEditCustomer(null, {
    
            beforeShown: function (addEditScreen) {
                // Create new Customer here so that
                // discard will work.
                var newCustomer = new myapp.Customer();
                addEditScreen.Customer = newCustomer;
            },
    
            afterClosed: function (addEditScreen, navigationAction) {
                // If the user commits the change,
                // show the new Customer in View Screen.
                if (navigationAction === msls.NavigateBackAction.commit) {
                    var newCustomer = addEditScreen.Customer;
                    myapp.showViewCustomer(newCustomer);
                }
            }
    
        });
    };

    Here's a sample application if you're intersted. http://sdrv.ms/11vbpYA

    Best regards,
    Huy Nguyen

    • Marked as answer by Sven Elm Wednesday, April 17, 2013 7:05 PM
    Wednesday, April 17, 2013 4:15 PM
  • Hi,

    Super nice. THANKS!

    regards

    Sven


    Sven Elm

    Wednesday, April 17, 2013 5:43 PM