locked
Create Entity by using screen and myapp in HTML client app: wich differences RRS feed

  • Question

  • Hello,in my App I have a Home screen, with "command" buttons.

    I have a table names Tappa (Tappe in plural)

    I'd like to write a method that show the AddEdit screen for Tappa, by using the code.

    Wich difference are between creating a new instance of Tappa via screen (I always have a problem with Intellisense and in the Home.js file Itellisense doesn't find screen.Tappe...why...I don't understand!!) or via myapp?

    Thanks!!!

    myapp.Home.NuovaTappa_execute = function (screen) {
        // Write code here
        //var newTappa = myapp.activeDataWorkspace.ApplicationData.Tappe.addNew();  
        
        //myapp.activeDataWorkspace.ApplicationData.saveChanges().then(function () {
        //    myapp.showAddEditTappa(newTappa);
        //});
    
        var newTapp = screen.Tappe.addNew();
        myapp.showAddEditTappa(newTapp);
        
    };
    

    Thursday, November 28, 2013 9:15 AM

Answers

  • VS 2013 both methods tell me that there are unsaved changes:

        var newTappa = screen.Tappe.addNew();
        //var newTappa = myapp.activeDataWorkspace.ApplicationData.Tappe.addNew();
    
        myapp.showAddEditTappa(newTappa);


    That's because you created a new entity and attempted to navigate away from the current screen to a new Add/Edit screen without saving it first.  To do what you appear to want to do, you should follow the examples described in Visual Studio LightSwitch Screen Navigation and Advanced JavaScript Examples.
    • Marked as answer by Angie Xu Monday, December 9, 2013 2:13 AM
    Thursday, November 28, 2013 10:16 PM

All replies

  • They are equivalent if I'm not mistaken.  myapp is a fully qualified property path that works even when screen is not in scope as the view model, such as in your code example.
    Thursday, November 28, 2013 9:50 AM
  • I don't understand..now, with VS 2013 both methods tell me that there are unsaved changes

    /// <reference path="../GeneratedArtifacts/viewModel.js" />
    
    myapp.BrowseTappe.NuovaTappa_execute = function (screen) {
        // Write code here.
    
        var newTappa = screen.Tappe.addNew();
        //var newTappa = myapp.activeDataWorkspace.ApplicationData.Tappe.addNew();
    
        myapp.showAddEditTappa(newTappa);
    
    };


    • Edited by lunardbz Thursday, November 28, 2013 11:13 AM
    Thursday, November 28, 2013 11:05 AM
  • VS 2013 both methods tell me that there are unsaved changes:

        var newTappa = screen.Tappe.addNew();
        //var newTappa = myapp.activeDataWorkspace.ApplicationData.Tappe.addNew();
    
        myapp.showAddEditTappa(newTappa);


    That's because you created a new entity and attempted to navigate away from the current screen to a new Add/Edit screen without saving it first.  To do what you appear to want to do, you should follow the examples described in Visual Studio LightSwitch Screen Navigation and Advanced JavaScript Examples.
    • Marked as answer by Angie Xu Monday, December 9, 2013 2:13 AM
    Thursday, November 28, 2013 10:16 PM