locked
Html Client: Use a sql view for list datasource and allow edits to detail records based on table RRS feed

  • Question

  • For a CRM app I have a SQL View (CustomersJoined) that aggregates some data. When clicking on this grid (ItemTap) I want to be able to edit the related table (Customers) with its child tables (Events, Contracts etc). Unfortunately the designer doesn't let me do this by default because it doesn't recognise the relation between the view and the Customer details (similar to this SL question).

    How can i now manually link these browse and AddEdit screens together?

    I've tried many ways like using the BrowseCustomer ItemTap execute event:

    myapp.BrowseCustomers.CustomersJoinedItem_ItemTap_execute = function (screen) {

    myapp.showAddEditCustomer({ beforeShown: function (addEditCustomerScreen) { var selectedCustomerID = screen.Customers.selectedItem.ID; var newCustomer = myapp.activeDataWorkspace.ApplicationData.Customers_SingleOrDefault(selectedCustomerID); addEditCustomerScreen.CustomerItem = newCustomer; } });

    };

    or inside the AddEditCustomer.created event:

    myapp.AddEditCustomer.created = function (screen) {
        screen.CustomerItem = myapp.activeDataWorkspace.ApplicationData.Customers_SingleOrDefault(screen.CustomerID); // passed as parameter
    
        // or:
        screen.details.dataWorkspace.ApplicationData.Customers.filter("ID eq 44211"); // 44211 used as static example CustomerID
    };

    This is my first LS app so please also point out the obvious. I wasn't able to figure it out after reading forumposts and articles for at least 4 hours.


    IT Architect www.Goyaweb.nl The Hague, The Netherlands

    Thursday, January 23, 2014 11:15 PM

Answers

  • ok figured it out. This is what I finally (after 2 more days of debugging) added to the itemtap execute event:

    myapp.showAddEditKlant(null, {
        beforeShown: function (addEditCustomerScreen) {
            screen.details.dataWorkspace.ApplicationData.Customers.filter("ID eq " + screen.Query1.selectedItem.ID).execute().then(function (results) {
                var FirstCustomer = results.results[0];
                if (FirstCustomer != undefined && FirstCustomer != null) {
                    addEditCustomerScreen.CustomerItem = FirstCustomer;
                }
            });
        }
    });


    IT Architect www.Goyaweb.nl The Hague, The Netherlands

    • Marked as answer by Yannick Smits Tuesday, January 28, 2014 5:58 PM
    Tuesday, January 28, 2014 5:58 PM