Discussions

 View Only
Expand all | Collapse all

conditional dropdown with add a record - populate child field from parent

  • 1.  conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 17:51
    I have two tables - company and contact.  One company (parent) has many contacts (child).

    I create a company.  Then click Add a contact.  The contact  form opens in another window - but the company field (showing what parent it is under) is not populated.

    a) why does the form open in another window?

    b) how can I automatically get the company field to populate with the company the contact is being added to?


  • 2.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 18:29
    Are you using the button automatically created when you created the relationship? If it opens in a new window, it's because you have "Open Target in New Window" selected in the options portion of the field properties. The parent should always populate. You need to check the formula. Feel free to add the formula in your post.


  • 3.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 19:34
    yes, I'm using the button.

    It has this:

    URLRoot() & "db/" & [_DBID_CONTACTS] & "?a=API_GenAddRecordForm&_fid_39=" & URLEncode ([Record ID#])& "&z=" & Rurl()

    It seems that when I save the parent first, then click on Add Contact, it works properly.  I have
    "Save parent record automatically when a child record is created" checked on both tables (because sometimes I'm wanting to create a Company from another table/ parent record).  So it's acting like it doesn't actually save the Company (parent record) before trying to add the child.

    And it doesn't actually connect the two - the contact is saved, with no company.


  • 4.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 19:40

    charlotte

    The "Save Parent record automatically when a child record is created" is for when you have an embedded editable child report in the parent record being displayed in the form. So, if you make edits to the parent, then go to the embedded child report, which would be in edit mode too, and enter a new record there, then both child and parent changes or additions are saved.



  • 5.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 19:46
    Actually the "Save Parent record automatically when a child record is created" is for when you are in Add mode on a Parent and then user clicks to Add Child before saving the parent.  It will auto save the Parent and then go on to put up the Add Child form.


  • 6.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 19:49
    Exactly.... but that is what it does not seem to be doing. I am in add mode on the parent, then click to add the child.  The form to add a new child opens, with no link to the parent.  What am I doing wrong?


  • 7.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 20:31
    Charlotte, In your formula it is populating field ID# 39  in the child table with the [Record ID#] of the Parent.  Can you tell me what the field ID# is for the field called [Related Parent] in the child table.  I bet it is not fid 39.

    Also, what is the key field of the Parent record.  Is it still [Record ID#] or was it changed.


  • 8.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 20:36
    It was because the "save first" doesn't work when you ask for a new window. It works fine if you don't. (I think that might be a bug (!) 

    See below, for another wrinkle on this - when you access company through the picker, not directly via a button to get to the "add company" form. 


  • 9.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 21:00
    FYI, the 'save parent automatically' function is only evaluated it the original page is being redirected.  i.e. somebody tries to navigate away.  
    It has nothing to do with embedded reports or child records.  

    So you are correct, that it wont work when you open in a new window/tab.


  • 10.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 21:27
    So unfortunately, that seems to mean it won't ever be  evaluated if you got to the Add (company) page from a picker form - which I have to do because there are over 1000 records in the parent table.  See note below. Is there some way around this?


  • 11.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 21:32
    One option, that we have utilized for this workaround, is to have the 'add activity' button be launched from the companies table.

    i.e. Its a workflow change so people find the company first, or the contact first, then click 'add activity'  thus all the info is pre-populated.  If they can't find the company, or contact, they would add them first, then add the activity.

    Other than that, you could utilize some script to match the records up later, but the spelling would have to be perfect, and is not a great option.

    (this is one of the limitations of SQL database structures and conditional dropdowns)


  • 12.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 20:00
    You have the target set to open in a new window. Remove that option and it will work. I just tested it on one of my apps.


  • 13.  RE: conditional dropdown with add a record - populate child field from parent

    Posted 03-26-2018 20:30
    Yes, I see that now.  That one is fixed.

    Here is another version of this same problem, with a different setup from a programmer's POV, but the same in the Users eyes. It works differently.

    Suppose I start with an Activity, which has a related Company and Contact.

    On the Add Activity form I have a conditional dropdown so that I can only see the contacts related to the company if I pick the company first.  That works great.

    Now, suppose the company doesn't exist yet.

    I have more than 1000 companies, so QuickBase forces the company picker.  The user does browse, doesn't see it, and clicks Add Company from within the picker window.  The company can be added.   Now, when the user picks Add Contact at this point from the button at the bottom of the Add Company form, QuickBase closes the Add Company window and returns to Add Activity.  You can't use the "Add Contact" button from the Add Company form when you get to it through the picker.

    And, since the Contact dropdown in  the Add Activities form is conditional on the Company, there are no Contacts in the dropdown list.  If you try to Add a contact, you can do it, but you have to go back and choose the new company you just added.

    Is there a way I can tell it that the contact I'm adding should be connected to the company i just added. It seems to lose the company when adding a contact, if I got to the company through the picker.

    The picker.... is picky.