locked
How do I add a new child record? (HTML Client) RRS feed

  • Question



  • I cannot get child records to be added to a parent record.

    How do I set it up to add a new certification to the selected employee using Lightswitch 2015 and HTML Client?

    I have EMPLOYEE and CERTIFICATIONS tables, employees can have multiple certifications.

    In my Employee Add/Edit screen I want to display all the employee certifications.  But just clicking the "Add Certifications" link in the left of the Screen designer does not work.  After some fiddling it either shows ALL certifications (for all employees) or none at all.

    I got it to work by creating a query from Certification that requires a parameter of EmployeeID.  At the screen this parameter is bound to Employee.ID.  Now this works great, but...

    Here's where I am stuck:
    ------------------------
    When I try to add a new certification, I still have to supply the EmployeeID.  If I do not, a new row is created in Certifications with NULL in the Employee column.  Lightswitch gives me a lookup to choose the Employee ID on the screen, but of course I want this to be automatically filled in.  

    Do I need to use another parameter for the Certificate Add/Edit screen?  Shouldn't Lightswitch already know which ID to put in there?

    Are my expectations incorrect?  What am I missing?

    I am using VS2015, creating an HTML client project.  I've looked online and the examples show it automatically working, but these are for desktop versions and older versions of Lightswitch/Visual studio.

    Please, any help is appreciated.


    TIA

    Thursday, November 17, 2016 1:09 AM

Answers

  • This should be automatic.  Something is wrong with the relationships between your entitles. 

    If you're using LD intrinsic database, then try creating a new screen set to see if it works on the new screens.  If yes then you probably added the relationships after you created the first screens and LS is confused.

    If you're using an external database, then see this:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/deab3848-e2c3-4f0b-9f1b-5ea9b1014814/lightswitch-2013-how-to-save-nested-addedit-screen-data-before-coming-back-to-first-screen?forum=lightswitch

    HTH,

    Josh

    • Marked as answer by TCorpSoc Thursday, January 19, 2017 12:20 AM
    Sunday, December 11, 2016 2:36 PM

All replies

  • Do you have any update?
    Wednesday, November 30, 2016 8:54 AM
  • This should be automatic.  Something is wrong with the relationships between your entitles. 

    If you're using LD intrinsic database, then try creating a new screen set to see if it works on the new screens.  If yes then you probably added the relationships after you created the first screens and LS is confused.

    If you're using an external database, then see this:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/deab3848-e2c3-4f0b-9f1b-5ea9b1014814/lightswitch-2013-how-to-save-nested-addedit-screen-data-before-coming-back-to-first-screen?forum=lightswitch

    HTH,

    Josh

    • Marked as answer by TCorpSoc Thursday, January 19, 2017 12:20 AM
    Sunday, December 11, 2016 2:36 PM
  • I went back and rebuilt the project, from a simpler data source (the original db was imported from somewhere and a bit messy) and built it up from there. Although the relationships were all the same, there must have been something bad in the original database, because the new one worked fine. thanks!

    TIA


    • Edited by TCorpSoc Thursday, January 19, 2017 12:20 AM
    Thursday, January 19, 2017 12:20 AM