Skip to content
QuickbaseAdmirer edited this page Mar 13, 2013 · 3 revisions

Welcome to the Quickbase-JavaScript wiki!

December 2012 Update: As part of the upgrade to new QuickBase, customers using the www.QuickBase.com URL will be assigned an account URL. Account URL will look like mycompany.quickbase.com. SDKs or external scripts that access apps in your account must use this account URL. More information is available under QuickBase User Assistance

NOTE: QuickBase recommends that you use application tokens when working with the JavaScript SDK. For more about application tokens and for more about using tokens with QuickBase SDKs

Alternatively, you can leave tokens disabled for the application your scripts are calling.

to make use of the functionality of QuickBaseClient.js in your own HTML page you'll need to include the following HTML:

<script language="JavaScript1.2" src="/js/QuickBaseClient.js"></script>

HTML pages using QuickBaseClient.js must be hosted within QuickBase applications as file attachments or as text pages Customize->Application->Pages (Overview, etc.)->Create a New Page because web browsers only allow JavaScript code to access the web site the JavaScript originated from.

Since the methods of QuickBaseClient in many cases return an XML DOM, it may help to bone up Microsoft's XML DOM. Go to msdn.microsoft.com and search for "XML DOM". QuickBaseClient now also works in FireFox, Chrome and Safari.

To understand the arguments to the methods below please refer to the QuickBase HTTP API documentation

Many of the methods below require a dbid. The dashboard page of all QuickBase applications have a dbid that does not refer to any of the tables in the application. You must navigate to a form or view that is specific to your table to cause the proper dbid to appear in your browser's address bar. To learn more please read about dbids

The QuickBase JavaScript SDK is a JavaScript object that you instantiate like this:

var qdb = new QuickBaseClient();

now the variable qdb is a pointer to a QuickBaseClient object.

The QuickBaseClient object has the following properties and methods:

username Initially set to the empty string. Please refer to the QuickBase HTTP API documentation for more details.

password Initially set to the empty string. Please refer to the QuickBase HTTP API documentation for more details.

ticket Initially set to the empty string. A valid and unexpired ticket can be used instead of a username and password. Please refer to the QuickBase HTTP API documentation for more details.

errorcode Initially set undefined but will hold the numeric value of each QuickBase error code. Please refer to the QuickBase HTTP API documentation for more details.

errortext Initially set undefined but will hold the short text description of each QuickBase error. Please refer to the QuickBase HTTP API documentation for more details.

errordetail Initially set undefined but will hold the detailed text description of each QuickBase error. Please refer to the QuickBase HTTP API documentation for more details.

errormessage Initially set undefined but will hold the short and detailed text description of each QuickBase error

Authenticate (username as string, password as string) returns nothing Sets the username and password properties simultaneously and sets the ticket property to the null string. Please refer to API_Authenticate in the QuickBase HTTP API documentation for more details.

GetTicket () returns a string that is the ticket if successfull. Please refer to API_Authenticate to understand the side effects of calling this method. This call will actually log the user into QuickBase with the username and password last provided to the Authenticate method above. All other methods, including Authenticate, do not result in having a QuickBase ticket cookie pushed back to the browser.

GetSchema (dbid as string) returns an XML DOM. Please refer to API_GetSchema in the QuickBase HTTP API documentation for more details.

GetDBInfo (dbid as string) returns an XML DOM. Please refer to API_GetDBInfo in the QuickBase HTTP API documentation for more details.

CloneDatabase (dbid as string, newdbname as string, newdbdesc as string) returns newdbid as string Please refer to API_CloneDatabase in the QuickBase HTTP API documentation for more details.

AddField (dbid as string, label as string, type as string, mode as string) returns fid as string Please refer to API_AddField in the QuickBase HTTP API documentation for more details.

DeleteField (dbid as string, fid as string) returns nothing Please refer to API_DeleteField in the QuickBase HTTP API documentation for more details.

SetFieldProperties (dbid as string, fid as string, propertyName as string, value as string) returns XML DOM Please refer to API_SetFieldProperties in the QuickBase HTTP API documentation for more details.

FieldAddChoices (dbid as string, fid as string, choices asJavaScript array of string) returns numadded Adds options to a multiple-choice field. The choices array contains the option values to be added. Please refer to API_FieldAddChoices in the QuickBase HTTP API documentation for more details.

FieldRemoveChoices (dbid as string, fid as string, choices asJavaScript array of string) returns num removed Removes options from a multiple-choice field. The choices array contains the options to be removed. Please refer to API_FieldRemoveChoices in the QuickBase HTTP API documentation for more details.

GrantedDBs (withembeddedtables as string, Excludeparents as string, adminOnly) returns XMLDOM Please refer to API_GrantedDBs in the QuickBase HTTP API documentation for more details.

AddRecord (dbid as string, recordArray as JavaScript array) returns XML DOM The array must contain an even number of elements. The first in each pair of elements is either the field identifier or fid of the field in question. Or it can be the field's name. The second in each pair of elements is contents for that field. Please refer to API_AddRecord in the QuickBase HTTP API documentation for more details.

EditRecord (dbid as string, rid as string, recordArray as JavaScript array) returns XML DOM The array must contain an even number of elements. The first in each pair of elements is either the field identifier or fid of the field in question. Or it can be the field's name. The second in each pair of elements is contents for that field. Please refer to API_EditRecord in the QuickBase HTTP API documentation for more details.

DeleteRecord (dbid as string, rid as string) returns XML DOM Please refer to API_DeleteRecord in the QuickBase HTTP API documentation for more details.

DoQuery (dbid as string, query as string, clist as string, slist as string, options as string) returns XML DOM query argument can be either the qid of a saved view, the name of a saved view or an actual QuickBase query string that starts and ends with curly braces. Please refer to API_DoQuery in the QuickBase HTTP API documentation for more details. The XML DOM that comes back will have negative UID numbers as the contents of user fields. If there are user fields in the query results, the returned XML DOM will have a section that translates the UIDs into either email addresses or screennames depending on whether the user has a screenname or not. The following line of code will translate a userid into an email address or screenname:

var userName = qdb.selectSingleNode(xmlDOMFromDoQuery, "/*/table/lusers/luser[@id='"+userid+"']");

PurgeRecords (dbid as string, query as string) query argument must be an actual QuickBase query string that starts and ends with curly braces. Please refer to API_PurgeRecords in the QuickBase HTTP API documentation for more details. ImportFromCSV (dbid as string, CSV as string, clist as string, rids as string Array, skipfirst as string) returns the number of records modified or added Please refer to API_ImportFromCSV in the QuickBase HTTP API documentation for more details.

displayErrorAlert (message as string) returns true if the last QuickBase returned a non-zero error code otherwise false. Before returning true this method displays the message argument followed by the errormessage property in an alert dialog box.

ParseDelimited (data as string, delim as string) returns JavaScript array of JavaScript arrays The returned array contains an array for every line in the "data" string. The array for each line contains an element for each piece of data delimited by the "delim" string. Quotes are used to surround data containing hard returns and delimiter characters. Quotes are escaped by doubling them up. This is useful if you want to convert text a user has pasted into a text area from Excel into CSV. Excel puts text data on the clipboard in tab delimited form. API_ImportFromCSV only accepts data in CSV form.

parseQueryString () returns JavaScript array of query string parameters The array is indexed by the name of the query string parameter.

DisplayDate (XML DOM) returns string formatted mm-dd-yyyy Assumes the first node in the DOM is a text string representing a number of milliseconds since 1/1/1970 midnight GMT. QuickBase presents its dates in XML form as milliseconds since 1/1/1970 midnight GMT. So this is a handy way to convert the output from the QuickBase XML HTTP API into human readable form.

format (data as string, format as string) returns string data contains a string or number representing the number of milliseconds since 1/1/1970 00:00:00 GMT for dates or just the time of day in milliseconds since midnight. format can start with either "date" or "timeofday". If format starts with "date" and contains the word "friend" then the returned value is of the form "January 11, 2004". If format contains "long" then the returned value is of the form "Wednesday, June 5, 1999". If format contains "timestamp" then the returned value is of the form generated by the JavaScript toLocalString method. If format starts with "timeofday" then the returned value is of the form HH:MM.

Clone this wiki locally