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

  • 0
  • 1
  • Question
  • Updated 8 months ago
  • Answered
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?
Photo of Charlotte

Charlotte

  • 450 Points 250 badge 2x thumb

Posted 8 months ago

  • 0
  • 1
Photo of Gil Spigelman

Gil Spigelman

  • 870 Points 500 badge 2x thumb
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.
Photo of Charlotte

Charlotte

  • 450 Points 250 badge 2x thumb
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.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 50,038 Points 50k badge 2x thumb
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.
Photo of Charlotte

Charlotte

  • 450 Points 250 badge 2x thumb
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. 
Photo of Matthew Neil

Matthew Neil

  • 31,418 Points 20k badge 2x thumb
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.
Photo of Charlotte

Charlotte

  • 450 Points 250 badge 2x thumb
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?
Photo of Matthew Neil

Matthew Neil

  • 31,418 Points 20k badge 2x thumb
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)
Photo of Gil Spigelman

Gil Spigelman

  • 870 Points 500 badge 2x thumb
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.
Photo of Charlotte

Charlotte

  • 450 Points 250 badge 2x thumb
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.