API_EditRecord is another basic API component that allows the user to make an edit to a single record in Quick Base
Common use cases for using the API_EditRecord might include:
Imagine a scenario where you want to approve a record in Quick Base. You want to mark the record as approved, log the date it was approved and log the current user as the approver. To do so, you could create a button that uses API_EditRecord to create a seamless workflow.
Let’s start with the Quick Base documentation example Request and break it down into its components.
The Quick Base example from their documentation is as follows:
Part 1 – the Target
The target is the Quick Base table you want to add a record in. The colored text below represents the target.
The target_domain is your Quick Base realm. In my case, my Quick Base realm is quandarycg.quickbase.com. So, the first part of my URL would look like –
The target_dbid is the table you want to edit a record in. Every table in Quick Base is uniquely identified by a table id. To find your unique table id, navigate your browser to the table where you are trying to edit a record. Once there, take a look at your browsers URL – the text you are looking for is the string of characters that immediately follow after the “/db/”, and stops before the “?a”. In the case of the Quandary CG Knowledge Base, we have a table for ‘External Records’ to hold test data from Knowledge Base users. That table is found via the following link for us:
The Target DBID then, is bn6wwekqv.
Once you have your Quick Base realm and your target DBID, you bring it all together to build your Target for this API call. From the above examples -
Part 2 – the API Call
The API call is how you tell Quick Base what you are trying to do. It is the core piece that determines how Quick Base interprets everything else and what it needs from you. Everything in the API call should start with “?a=API_”. Since this document is about editing records, your full API call should read as “?a=API_EditRecord”. Make sure you do not forget the “API_” piece.The updated URL will be as follows:
Part 3 – Using App Tokens
Depending on your app – Application Tokens may or may not be required. For more info on how to use app tokens, please reference the Application Tokens article. If they are required, then your URL needs to call out that essential piece. Doing so requires that you add “&apptoken=” as the next part of your URL.The updated URL will be as follows:
Part 4 – Authentication/Ticket
A requirement of an API call is that the user or process making the call be logged in or authenticated in some form. For simplicity - I recommend using User Tokens. For an explanation of user tokens, please reference the User Tokens article. Incorporating a user token is similar to using apptokens, whereby you add an additional URL param to your API call for Quick Base to read. That string is “&usertoken=”. The updated URL will be as follows:
Part 5 – Establishing the RID
Since we are editing an existing record in Quick Base, part of your API_EditRecord needs to call out which record you want to edit. Doing so requires that identify somewhere in the URL string, the rid or the key of the record you want to change.
If you have set up your table to use a different Key field other than Record ID#, you can use the ‘key’ parameter. Otherwise, the more common usage and what will be detailed below is using the standard Quick Base Record ID# and the rid param.
To set your rid value – we will continue with the existing URL, and append a new param for ‘rid’, similar to below.
*Where 12345 is the Record ID of the record you want edited
Part 6 – Setting Field Values
The last part of this process is determining what fields you want changed, and what values to change them to.
Setting different field values is just a matter of rinse and repeat using &_fid_#=. Make sure the field ID of the various inputs you want to set in the target table. Before you set up your API call, you should identify the various inputs you want to set and their associated Field IDs. With those identified, you will append &_fid_#=value to your URL string for each field you want a value set for. For example,
Field ID 6 = the Approval Status
Field ID 7 = the Approval Date
Field ID 8 = the approver
Your complete URL thus far would be -
Part 7 – Test it
To see it in action – head over to the Knowledge Base and try it out
In opposition to editing records - check out API_PurgeRecords for more info on how to remove records.
Author: Chayce Duncan (email@example.com)
Date Submitted: 12/19/18