URL Button to Update Parent Record

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

I ran across this post from 3 years ago when trying to update my parent record (Products)from a URL Button on a child record (Inventory Adjustments.)

This was the original question:

I have searched and have not quite found the answer I am looking for... I have 2 Tables, Table 1 is Store Contact (Parent) and Table 2 is Calls (Child) In Store Contact Table 1, I have to look-up fields:  Store MGR Name & Store MGR Email

·        When a new record is added in Calls, I have the following: The Store Manager Name and Email that is pulled from the Store Contact Table. The problem is when the Manager changes I want the user to be able to use a check box to initiate the Update Name and Email (hidden before box is checked). Then when the user saves the record I would like for the updated name and email address to update the parent record in the Store Contact Table. How do I go about doing this?

This was the answer posted by Mark:

I don't know of a way to do this "on save", but you can make a URL formula field to be pushed by the user to push up the data from a child to a parent.  The button would need only be visible in view mode to be sure that the data is saved before you push the button.

This could create a problem, because you may have the add Call button set to return to the Parent Store record after saving.

But the the formula is going to look something like this

URLRoot() & "db/" & [_DBID_ORDER__NOTES]
& "?act=API_EditRecord&rid=" & [Related Store #]
& "&_fid_11=" &  [Order #]
& "&_fid_7=1"
& "&_fid_6=" & URLEncode("email triggered to Customer Service with the Note above")
& "&_fid_8=" &  URLEncode([Rep Name])
& "&_fid_9=" &  URLEncode([Acct Name])

You would need to put in your dbid for your parent table, and the fid's from the parent, but the value fields from the child.

Here's my new question:

I applied the above answer to my current URL button and it looks like this:

URLRoot() & "db/" & [_DBID_PRODUCTS]
 & "?act=API_EditRecord&rid=" & [Item Code]
 & "&_fid_204=" &  URLEncode([New NS Item Code])

This works and updates the parent record as desired however I still receive the following error message.

<qdbapi> <action>API_EditRecord</action> <errcode>0</errcode> <errtext>No error</errtext> <rid>87</rid> <num_fields_changed>1</num_fields_changed> <update_id>1434001822957</update_id> </qdbapi>

What did I leave out of my formula that is making this error appear? Like I said before, the parent record is updating like I need it to. I'd just like to eliminate the error message.

Thanks!



Photo of Andrea

Andrea

  • 90 Points 75 badge 2x thumb

Posted 4 years ago

  • 0
  • 1
Photo of QuickBasePros_IDS

QuickBasePros_IDS, Champion

  • 4,464 Points 4k badge 2x thumb
What you are seeing is NOT an "error", it is an XML return of the action taken by QuickBase.  

<qdbapi> <action>API_EditRecord</action>   //action QB took <errcode>0</errcode>   //error code (there isn't one) <errtext>No error</errtext>   //No error <rid>87</rid>   //record ID# QB changed <num_fields_changed>1</num_fields_changed>  // how many fields in the record changed <update_id>1434001822957</update_id></qdbapi> You have left out the Redirect which will return the User to a page/record of your choosing.  This formula represents your modified formula to redirect to a table record when the [Related Reference Field] value is known for that table in the record you have your button.

URLRoot() & "db/" & [_DBID_PRODUCTS] 

 & "?act=API_EditRecord&apptoken=xxxx&rid=" & [Item Code]

 & "&_fid_204=" &  URLEncode([New NS Item Code])

 & "&rdr=" & URLEncode(

URLRoot() & "db/" & [_DBID_ORDERS] 

 & "?a=dr&rid=" & URLEncode([Orders Table Record ID#]))

You can choose where to redirect the User in different ways:


1.  Display the record they just updated2.  Return the user to the page they were on3.  Return the user to a different table/record (provided you have the Key field value in the table you came from)4.  Return the user to a hard-coded location (like a report)5.  Return the user to the table dashboard or home page
Note that if you have Application Tokens turned on; you will need that apptoken to use the API.  Also, you can write this formula slightly simpler as follows (it's what you get used to):
URLRoot() & "db/" & [_DBID_PRODUCTS] 

 & "?act=API_EditRecord&apptoken=xxxxx&rid=" & [Item Code]

 & "&_fid_204=" &  ([New NS Item Code])

 & "&rdr=" & URLEncode(

URLRoot() & "db/" & [_DBID_ORDERS] 

 & "?a=dr&rid=" & ([Orders Table Record ID#]))

Please let me know if you have any problems.  Remember also that application tokens exist for a good reason; and you should ideally turn them on.  There are some instances where you have to turn them off.
Photo of Andrea

Andrea

  • 90 Points 75 badge 2x thumb
Thank you! I'd like to redirect to option #3 - different table/record. I do have the key field value in the table and that  field name is [Sold on Order]. (Additional info if needed... the table I want to redirect to is _DBID_ORDERS)
Photo of QuickBasePros_IDS

QuickBasePros_IDS, Champion

  • 4,464 Points 4k badge 2x thumb
I have updated my original response with the updated formula as well as some other info that may be useful to you.
Photo of Andrea

Andrea

  • 90 Points 75 badge 2x thumb
Hmmm, this isn't working. I've updated my formula with the one you have above and it's unable to find the Order. The message is "Order not found." We do have app tokens turned off but we use exact forms and I read that we need them off in order to use exact forms. Is that correct?
Photo of Andrea

Andrea

  • 90 Points 75 badge 2x thumb
I got it to work! I tried to fix it before I wrote back but of course, once you ask for help you figure it out. Apparently I was referencing the wrong field from my table. I was referencing the "Text (reference proxy)" field from the Orders table relationship not the "Numeric (reference)" field. Was my issue because QB was unable to reference a text field and needed to reference the numeric field instead?
Photo of QuickBasePros_IDS

QuickBasePros_IDS, Champion

  • 4,464 Points 4k badge 2x thumb
You need to use the Key Field of the table you are going to.  Most commonly this is the [Record ID#] field in the table.  Notice that in the code the URL has &rid - this means "and record ID".  If you had changed the Key Field of the table to a Text Field, you would use &key instead of &rid.  You must use the Key Field of the table you are pointing to in your formula URL.

I have taken the liberty of updating my original answer to reflect that the [Record ID#] of the table should be used when using &rid in formulas.
Photo of Andrea

Andrea

  • 90 Points 75 badge 2x thumb
Perfect, thank you again for your help!