locked
Newbie - Details screen with children and grandchildren RRS feed

  • Question

  • I have a simple situation that seemed to work fine in Beta 1.

    Guardian (parent) record with a datagrid of invoices (children) and related datagrid of invoice items (grandchildren).  In addition there is another datagrid of payments (children).

    When the screen is first created, I get an "object not set..." error - though it takes quite a while for it to come up.  Close the screen and open it again on that guardian or any other and it works.

    It is clearly bent about the invoice items (grandchildren).  I've taken that datagrid off the screen and everything works fine.  I check in the debugger and the query has executed on the grandchildren just fine.

    The datagrids are in a tab control.

    I was just recreating what I had done in Beta 1 to get back on track with the project.

    Reworking the interface to get around it, but I thought it was worth mentioning.

    TIA - Great product. 

    Monday, March 28, 2011 3:34 PM

Answers

  • Hi Mark,

    Would you happen to be using Beth Massi's add/edit screen nmethod?

    How are you setting the screen's entity property in IInitializeDataWorkspace? Are you settig's its value to that of another scren query property (as Beth's method indicates)?

    I have seen several peoplerun into this problem when using Beth's method excatly as she describes. I use a slightly modified version of it, & each time someone uses the modified version, the problem seems to go away.

    Instead of Me.EntityProperty = Me.Entity, I use Me.EntityProperty = Me.DataWorkspace.DataSource.Entities_Single(Me.EntityID)

    You can see an example of such a problem being solved here http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/e375af30-d61d-447c-af12-e425de0431f9.

    Yann

    Monday, May 2, 2011 12:42 PM

All replies

  • Hi,

    Could you provide more details? Is this the intrinsic database or an attached database, or a mix? Can you always repro the "object not set" error? Is this a List and Details screen? What do you mean by "I check in the debugger and the query has executed on the grandchildren just fine." - what are you checking in the debugger?

    Regards,


    Steve Hoag Microsoft aka the V-Bee
    Sunday, April 3, 2011 7:15 AM
    Moderator
  • Sorry, I guess I wasn't clear enough.  I gave up on that precise example and just reworked the UI not to have the children/grandchildren display so that I could get back to finishing things off.  However, it shows up again in another similar scenario, where I am trying to set the "can execute" on a button I added to a datagrid of children.

    I am using a datasource that is a MSSQL database with multiple tables and relations set in them.  While there is one hand created entity in the project, it's not involved in this.

    I am using a Search screen to select an item and open a Details screen, passing in an ID as a parameter.

    The problem comes when I try to check the status of the child records in a "can_execute" procedure.  I did a little testing and here's what I discovered:

    1. I launch the details screen from a parent search screen.
    2. The "data initialize" method executes
    3. The "loaded" method executes
    4. The "can_execute" executes without a problem and putting a break in that method and using the quickwatch to explore the values, indicates that I have the correct record and all the related child records and their values are correct.
    5. The "childlist loaded" method executes
    6. The "can_execute" method fires again and executes again without a problem.
    7. The "screen created" method executes
    8. The "can_execute" method fires a third time and at this point, any reference to me.entityproperty causes the system to go away for a while and then timeout.  Eventually I get an "object not set to a reference" error.
    9. Without exiting the application, I close that screen and relaunch from the previous search list again and everything works fine.  Same records.  If I launch a different record from the search screen (opening up a new screen) it works just fine - in fact, while the other is still timing out.

    This reproduces faithfully each time I try it.

    My workaround was to put a boolean in place to track when the "created" method executed to prevent the can_execute from checking anything.  I reenabled the boolean on the child table "selection changed" event which eventually fires when they click on an item.

    Ugly, but it's working.

    Tuesday, April 5, 2011 12:32 AM
  • Hi Mark,

    Would you happen to be using Beth Massi's add/edit screen nmethod?

    How are you setting the screen's entity property in IInitializeDataWorkspace? Are you settig's its value to that of another scren query property (as Beth's method indicates)?

    I have seen several peoplerun into this problem when using Beth's method excatly as she describes. I use a slightly modified version of it, & each time someone uses the modified version, the problem seems to go away.

    Instead of Me.EntityProperty = Me.Entity, I use Me.EntityProperty = Me.DataWorkspace.DataSource.Entities_Single(Me.EntityID)

    You can see an example of such a problem being solved here http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/e375af30-d61d-447c-af12-e425de0431f9.

    Yann

    Monday, May 2, 2011 12:42 PM
  • That's fantastic! You're welcome..
    Tuesday, May 3, 2011 4:27 AM
  • Steve,

    I wish I was arguing for someone else's answer, instead of one of mine, but I think you've marked the wrong answer here. This post mainly mainly describes the problem, a fairly ugly (& actually unnecessary) workaround.

    I think you'll agree that the later post, where I describe a method that has actually solved a few people's similar problems, & that Mark himself says "I've done what you described and that cured my problem.  I'm no longer seeing this behavior" would seem to be a more accurate answer than the workaround, because it solves the problem & negates the need for any workaround.

    I see you've been catching up on marking answers for a lot of posts all at once, so I suspect you just missed the second answer.


    Yann

    (plus ça change, plus c'est la même chose!)

    Tuesday, July 26, 2011 3:51 AM
  • Yann,

    Sorry, you're right - I didn't read far enough.

    I'm trying to clean up as many threads as possible tonight before we shut down and archive the forum tomorrow. Threads marked as answers have better visibility, if someone finds the archived posts via a web search.

    Regards,


    Steve Hoag Microsoft aka the V-Bee
    Tuesday, July 26, 2011 3:56 AM
    Moderator
  • That's fine, I figured that's what had happened.

    Yann

    (plus ça change, plus c'est la même chose!)

    Tuesday, July 26, 2011 4:13 AM