Click a button in email notification to change field in different table

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
I would like to have a button in an email notification that checks a box when clicked. However the email notification is located in a different table from that of the checkbox.

I am getting error codes when clicking the button. I have made buttons before but error codes keep showing up. 
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb

Posted 1 year ago

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

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
Please post you code for the button and the error
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
URLRoot() & "db/" & [_DBID_Contracts] & "?act=API_EditRecord&rid=" & [SAP Contract #]

& "&apptoken=b9pzvpjdbfk42zck9xawjk99nx5"

& "&usertoken=b27z4b_xfm_b57dsvw279ijqcf93f6cdaj7y4f"

& "&_fid_282=true"


ERROR Code:
<qdbapi><action>API_EditRecord</action>
<errcode>30</errcode>
<errtext>No such record</errtext>
<errdetail>
Sorry, there is no record in this application table with the record identifier (rid) of "800275310".
</errdetail>
</qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
To edit a record you need to specify the record I'd or the key field value.


There is no way that you have a Record ID of 800 million. So either you need to change to this


&rid=" & [Record ID#]


Or else


&key=" & [SAP Contract #]


If that SAP Contract was the Key field.
(Edited)
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
I changed it to &rid="& [Record ID#] and got the error:
Sorry, there is no record in this application table with the record identifier (rid) of "5"
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
The button is on table A. But you want to edit a record on another table, table B. Which record do you want to edit? You need to specify either the record ID number or the Key field of table B.

Once that works you will then have to decide where you want to leave the user or else the system will put up a success message in the screen which you will want to suppress.
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
I want to edit table B. The Key field for both of the tables is the Record ID#. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
There are lots of records in table B. Which one do you want to edit.
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
the contract number was pulled in from the table B to table A (where the button is). I want to edit the record with that contract number. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
You can only edit a record if you know the Key field or the Record ID. You would need to be willing to change the Key field in stable B to be the SAP #.
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
So I was able to get the checkbox to work (I just pulled over the record ID# from table B instead of changing the key field). EXCEPT, I get an ugly error message when I click the button. The error message is:
<qdbapi>
<action>API_EditRecord</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<rid>1991</rid>
<num_fields_changed>1</num_fields_changed>
<update_id>1501208116824</update_id>
</qdbapi>
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
I fixed the error message, except when the button is clicked in the email, it takes me to the table A (where the button is located). I want it to take me to table B where the checkbox is located.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
Can you post your current code?
(Edited)
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
URLRoot() & "db/" & [_DBID_Contracts] & "?act=API_EditRecord&rid=" & [Contract - Record ID#]

& "&apptoken=b9pzvpjdbfk42zck9xawjk99nx5"

& "&usertoken=b27z4b_xfm_b57dsvw279ijqcf93f6cdaj7y4f"

& "&_fid_282=true"

& "&rdr=" & URLEncode(URLRoot() & Dbid() "?a=dr&rid=" & [Record ID#])

I'm thinking it is in the Dbid() part
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
Right. You want to land on the SAP table


So the ReDiRect needs to say


& "&rdr=" & URLEncode(URLRoot() & [_DBID_SAP_Table] & "?a=dr&rid=" & [Contract -Record ID#]


You will need to get the correct name for that SAP table from settings, for that table, and then Advanced Properties.
(Edited)
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
I get an error code of 83 when I put it in the email notification.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
Please post your current formula and the XML response
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
URLRoot() & "db/" & [_DBID_Contracts] & "?act=API_EditRecord&rid=" & [Contract - Record ID#]

& "&apptoken=b9pzvpjdbfk42zck9xawjk99nx5"

& "&usertoken=b27z4b_xfm_b57dsvw279ijqcf93f6cdaj7y4f"

& "&_fid_282=true"

& "&rdr=" & URLEncode(URLRoot() & [_DBID_Contracts] & "?a=dr&rid=" & [Record ID#])


ERROR CODE:
<?xml version="1.0"?>

-<qdbapi>

<action>API_EditRecord</action>

<errcode>83</errcode>

<errtext>Invalid error code: 83</errtext>

<errdetail>User token is invalid</errdetail>

</qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
It does not seem Tom like your usertoken. Is the usertoken enabled for the application which holds the record you are editing?
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
It is in the manage application tokens table within the App Properties. I'm not sure how to enable it though
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
The user tokens are different than an application token.

The user token allows a formula URL button to edit a record without the user needing to sign in.  The downside is that you will not know who actually clicked the button as it will always show the user of who owns the application token as the [Last Modified by]


The user tokens are obtained by clicking on your name at the top right and then "Manage Preference".  That is where you can create user tokens and assign their use to specific apps.

My guess is that the user token is either not correct or is not enabled for the app you are editing.
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
Sorry for the problems. This worked, the checkbox gets checked when clicked in the email notification, however I now get the error "We can't understand the URL you specified. If you think the URL is correct, try refreshing this page." Not sure how to get rid of this error
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
I can't read your mind as to what your current formula is.
I'm good, but not clairvoyant.
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
It is the same as above, I just put the user token in my preferences:

URLRoot() & "db/" & [_DBID_Contracts] & "?act=API_EditRecord&rid=" & [Contract - Record ID#]

& "&apptoken=*******************"

& "&usertoken=*****************"

& "&_fid_282=true"

& "&rdr=" & URLEncode(URLRoot() & [_DBID_Contracts] & "?a=dr&rid=" & [Record ID#]
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,928 Points 50k badge 2x thumb
Missung db/

& "&rdr=" & URLEncode(URLRoot() & "db/" & [_DBID_Contracts] & "?a=dr&rid=" & [Record ID#
Photo of Quinten

Quinten

  • 732 Points 500 badge 2x thumb
It worked! Thanks so much!