Traitée Control what screen to display after new data entered.

  • Thursday, January 31, 2013 9:13 PM
     
     

    I may have used the wrong screen template when I created my screens. I wanted to use the same screen to both enter new data and update existing data so I followed the Beth Massi video titled - "How Do I: Create a Screen that can Both Edit and Add Records in a LightSwitch Application?"

    Although the resultant screens work perfectly, a rather unpleasant side effect when creating new data is the fact that after the Save button is clicked the screen redisplays the data you just entered only this time it is in Edit mode instead of New Data mode. I would much prefer that after clicking on Save (and having no errors to correct) that the screen would simply close with the sending screen displayed and the refresh method invoked so the user doesn't have to go through a 3 step process of…  creating the data... clicking Save... then closing the tab... and then clicking refresh so the new record gets displayed.

    I'm assuming there must be a way to do that. I can't imagine users being very pleased with having to go through all those steps every time they create new data.

    Thanks

       

All Replies

  • Friday, February 01, 2013 4:00 AM
     
     Answered

    In your screen, click "write code".  In the method ScreenName_Saved(), change the code to show the screen you want to show:  Me.application.showScreenName()

    On the screen you send you them back to, click "write code".  In the _activated method, write:

    Me.collection.refresh()

    Change ScreenName to the name of your screen.

    Change  collection to the name of your collection in the screen.

    • Marked As Answer by Jyuma1 Friday, February 01, 2013 12:19 PM
    •  
  • Friday, February 01, 2013 12:20 PM
     
     
    Thank you.  It worked perfectly.