locked
Add new related entity RRS feed

  • Question

  • I am coding a Calling Log.  Some background:  Entities include Call, Caller, CallingOrganisation, CallQuery.  A Call comprises a date, recipient, and one to many CallQuery's.  (CallQuery's are question, detail, answer).  A Call is made by a Caller who may or may not be from a CallingOrganisation. Callers <=> CallingOrganisations are many to many as a Caller may change Organisation from time to time, and one Organisation may have multiple Callers.

    The Problem:  I am having issues trying to add a new Calling Organisation to a Caller.  Currently just working on the 'Add' scenario, where I create a new Caller and add a new CallingOrganisation to that Caller.   In my AddCaller screen, I have an auto complete box so the user can select the Organisation if it exists, and a button underneath, so the user can create a new CallingOrganisation if it doesn't exist.

    Clicking the button invokes the modal window I've added to the screen, but this doesn't allow me to populate any of the fields in the new CallingOrganisation.  The dialog is effectively read only, but my added Cancel and OK buttons are fine.

    My Code:  this invokes the modal window:

    partial void AddCallingOrg_Execute()    {

        // Write your code here.      

        newCallingOrg = new CallingOrganisation();

         this.OpenModalWindow("CreateCallingOrg");

       }


    I don't have 'Use Read Only Controls' set anywhere on the screen, so that's not it.

    I'm thinking that the modal window is trying to display the CallingOrganisation data related to the newly created Caller (which of course doesn't exist) rather than giving me empty fields to create a new, unrelated CallingOrganisation entity.

    How do I code the screen so the modal window a) Allows the creation of a new CallingOrganisation entity, and b) when the modal window is closed, sets the newly created CallingOrganisation as the CallingOrganisation for the newly created Caller entity?

    I am using the Desktop Client with VS2013, but have only migrated coz it seems that's where the love is.  Happy with an answer for either VS2012, or VS2013.

    If there is any code I haven't supplied, let me know.

    Many thanks


    • Edited by nob0dy Thursday, April 24, 2014 7:45 AM silly code formatter doesn't work
    Thursday, April 24, 2014 7:42 AM

Answers

  • The line of code you have here

      newCallingOrg = new CallingOrganisation();

    creates the CallingOrganisation object outside of any collection/query. Only objects that are in a collection/query will show on screen because that's what the screen controls are bound to.

    Try something like

      newCallingOrg = CallingOrganisations.AddNew;

    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    • Proposed as answer by Paul Van Bladel Friday, May 2, 2014 8:53 AM
    • Marked as answer by Angie Xu Monday, May 5, 2014 3:15 AM
    Friday, May 2, 2014 7:56 AM

All replies

  • "Clicking the button invokes the modal window I've added to the screen, but this doesn't allow me to populate any of the fields in the new CallingOrganisation. "

    Can you give some code about the explanation above?

    Friday, May 2, 2014 7:25 AM
  • The line of code you have here

      newCallingOrg = new CallingOrganisation();

    creates the CallingOrganisation object outside of any collection/query. Only objects that are in a collection/query will show on screen because that's what the screen controls are bound to.

    Try something like

      newCallingOrg = CallingOrganisations.AddNew;

    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    • Proposed as answer by Paul Van Bladel Friday, May 2, 2014 8:53 AM
    • Marked as answer by Angie Xu Monday, May 5, 2014 3:15 AM
    Friday, May 2, 2014 7:56 AM