QuickBase API Cookbook v3 - Recipe #114
Use object-oriented programming to interact with QuickBase
object oriented
You need to write code in an object-oriented style to interact with the tables, fields, records, queries, roles, users, variables, pages in a QuickBase application.
require 'QuickBaseObjects'

qbob = QuickBase::Objects::Builder.new("username","password")
  
myApplication = qbob.application("My Application")
  
puts "\n\nApplication name:\n"
puts myApplication.name

puts "\n\nApplication roles:\n"
myApplication.roles.each_value{|role|puts "name: #{role.name}, id: #{role.id}, access: #{role.access}"}

puts "\n\nApplication users:\n"
myApplication.users.each_value{|user|puts "id: #{user.id}"}

puts "\n\nApplication variables:\n"
myApplication.variables.each_value{|variable|puts "#{variable.name}: #{variable.value}"}

puts "\n\nValue of application variable 'TestVariable':\n"
puts myApplication.vTestVariable

puts "\n\nSet the value of application variable 'TestVariable':\n"
myApplication.vTestVariable="New value for test variable"

puts "\n\nApplication pages:\n"
myApplication.pages.each_value{|page|puts page.name}

puts "\n\nDefault application page:\n"
puts myApplication.pDefault_Dashboard.name
  
puts "\n\nTables from My Application:\n"
myApplication.tables.each_value{|table|puts table.name}
  
puts "\n\nQueries from the Contacts table:\n"
myApplication.tContacts.queries.each_value{|query|puts query.name}

puts "\n\nProperties of the List All query from the Contacts table:\n"
myApplication.tContacts.qList_All.properties.each_pair{|key,value|puts "#{key}: #{value}" }

puts "\n\nNames from the List All query from the Contacts table:\n"
records = myApplication.tContacts.qList_All.run 
records.each{|record| puts record.fName}

puts "\n\nColumns of the List All query from the Contacts table:\n"
puts myApplication.tContacts.qList_All.qyclst
  
puts "\n\nFields from the Contacts table:\n"
myApplication.tContacts.fields.each_value{|field|puts field.name}
  
puts "\n\nField ID of the Phone field in the Contacts table:\n"
puts myApplication.tContacts.fPhone.id

puts "\n\nName of field 7 from the Contacts table:\n"
puts myApplication.tContacts.fields["7"].name

The QuickBase::Objects::Builder class creates an Application object instance using the QuickBase schema for a specific application.  The application object will contain instances of table, query, variable, page, field, role, and user objects, each with methods matching the names assigned to these things in QuickBase.
This is done accomplished Ruby's ability to add methods to objects dynamically, which means that every time you run QuickBase::Objects::Builder for an application, the result will be in synch with the latest definition of the application in QuickBase.
 
application_object.rb
Created on June 12, 2009 at  9:59 PM (PDT). Owned by Quick Base.
Quick Base
Show fields from Show fields from Show fields from a related table
Report Name *
Description
Reports and Charts Panel
Each table has a panel listing its reports and charts, organized in groups.
Please wait while your new report is saved...
Field label
Column heading override
Justification
What does auto mean?
Fields in:

Fields to Extract:

Name for the new table:
Items in the new table are called:

When you bring additional fields into a conversion, Quickbase often finds inconsistencies. For example, say you're converting your Companies column into its own table. One company, Acme Corporation, has offices in New York, Dallas and Portland. So, when you add the City column to the conversion, Quickbase finds three different locations for Acme. A single value in the column you're converting can only match one value in any additional field. Quickbase needs you to clean up the extra cities before it can create your new table. To do so, you have one of two choices:

  • If you want to create three separate Acme records (Acme-New York, Acme-Dallas and Acme-Portland) click the Conform link at the top of the column.
  • If the dissimilar entries are mistakes (say Acme only has one office in New York and the other locations are data-entry errors) go back into your table and correct the inconsistencies—in this case, changing all locations to New York. Then try the conversion again.

Read more about converting a column into a table.

We're glad you're interested in doing more with Quickbase!

Now we need to make you official before you share apps or manage your account.

Verifying your email lets you share Quickbase with others in your company.

Your work email
Your company