What's wrong with this formula?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I'm starting to create a formula that, when clicking on the Add Contact Button, will copy over the address information from the parent record to the child record.  However, I keep getting a QB error that I just can't understand.  My formula looks correct, but obviously, it is not.

Formula:

URLRoot() & "db/" & [_DBID_CUSTOMERS] & "?a=API_GenAddRecordForm&_fid_36=" & URLEncode ([Record ID#])&

If([Address - Street 1]<>"",
"&_fid_45=&_fid76)&

"&z=" & Rurl()

Error Message:

Formula syntax error - The argument list of the function z must begin with a left parenthesis.

As far as I can tell, I have all the right parentheses.  

Any help?

Thanks

Michael Custer

Photo of Michael

Michael

  • 20 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,208 Points 50k badge 2x thumb
The first question would be as to why you want to do this, given that the child record can simply have a lookup field specified in the Relationship and you would lookup the value of the Customer Address down to the Child contacts.  (in my example I will assume that the Customer is the parent and the Contact is the Child record.

But if you did want to make the button do what you ask, you will need to populate each separate component of the Address field separately.  The field ID's for the target components are given in the field properties for the Target Address field.  The Address field type is different form any other feild type in how you refer to its value in a formula.  

For example if the field is called [Address] then the comonents can be referred to in the source table like

[Address: Street 1]

[Address: Street 2] etx and each component has its own name.



So the formula would read like




URLRoot() & "db/" & [_DBID_CONTRACTS] & "?a=API_GenAddRecordForm&_fid_36=" & URLEncode ([Record ID#]) 


& "&_fid_51=" & Urlencode([Address: Street 1])



& "&_fid_52=" & Urlencode([Address: Street 2])

& "&_fid_53=" & Urlencode([Address: City])

& "&_fid_54=" & Urlencode([Address: State/Region])


& "&_fid_55=" & Urlencode([Address: Postal Code])


& "&_fid_54=" & Urlencode([Address: Country])


& "&z=" & Rurl() // this will return you to the Parent Company record after saving




But like i said, it begs the question as to why you would not just use a lookup field to have Parent information being automatically populated into the child table.



Photo of Michael

Michael

  • 20 Points
Hey Mark, thanks for the help!  The reason I want it to copy and not just be a lookup field is because the Contact isn't always going to have the same address as the parent (company) address, just usually. That is why I want to copy the fields, which then leaves the option to change them if they aren't the same as the parent.  I will add that code in my formula and see how it goes.

Thanks!