QuickBase API Cookbook v3 - Recipe #116
Find QuickBase records by running a Windows batch file
find records batch windows
You want to find QuickBase records by typing a command at the Windows command prompt.

require 'QuickBaseClient'

def find_and_display_records
  
  puts "Connecting to QuickBase..."
  qbc = QuickBase::Client.init({"username" => ARGV[0] ,"password" =>  ARGV[1],"org" => ARGV[2]})
  qbc.cacheSchemas=true
  #qbc.printRequestsAndResponses=true
  
  puts "Accessing table #{ARGV[3]}..."
  qbc.getSchema(ARGV[3])
  
  search_value = ""
  (5..ARGV.length-1).each{|index|search_value << "#{qbc.encodeXML(ARGV[index])} "}
  search_value.gsub!("'","\\'")
  search_value.strip!

  print "Searching for '#{search_value}' ...\n"
  query = ""
  field_ids = ARGV[4].split(/\./)
  field_ids.each{|fid| 
    query << "{'#{fid}'.CT.'#{search_value}'}OR" 
  }
  query.slice!(query.length-2,2)
  
  rids = qbc.getAllValuesForFieldsAsArray(ARGV[3],["3"],query,nil,nil,"3")
  
  if rids and rids.length > 0
    if rids.length > 1  
      puts "Found #{rids.length} records. Retrieving HTML page..."
      qbc.cacheSchemas=true
      html = qbc.genResultsTable(ARGV[3],query,qbc.getFieldIDs(qbc.dbid).join("."))
      puts "Creating quickbase_find_results.html..."
      File.open("quickbase_find_results.html","w"){|f|f.write(html)}
      puts "Launching quickbase_find_results.html in browser..."
      system("start quickbase_find_results.html")  
    elsif rids.length == 1 
      puts "Found one record. Displaying record for edit..."
      rid = rids[0]["3"]
      puts "Launching QuickBase in browser..."
      system("start https://www.quickbase.com/db/#{ARGV[3]}?a=er^&rid=#{rid}^&username=#{ARGV[0]}^&password=#{ARGV[1]}")
    end
  else
    puts "Found no records. Launching QuickBase 'find' page..."
    system("start https://www.quickbase.com/db/#{ARGV[3]}?a=genadvfind^&username=#{ARGV[0]}^&password=#{ARGV[1]}")
  end
end

if ARGV[5]
  begin
     find_and_display_records
  rescue StandardError => error   
     puts "\n\nAn error occurred while looking for QuickBase records: #{error}\n\n"
  end
else
  puts "\n\nUsage: quickbase_record_finder <username> <password> <realm> <table_DBID> <field_IDs> <search_value>"
  puts "\ne.g: quickbase_record_finder fred.flintone@internet.com wilma www 8emtadvk 4.5.6 barney\n\n"
end
Download and extract the attached quickbase_record_finder.zip into C:\.
Modify the qbrf.bat file and put it in your Windows PATH.
quickbase_record_finder.zip
Created on Sept.  7, 2009 at  1:08 PM (PDT). Last updated by Quick Base on Sept. 21, 2009 at  8:59 PM (PDT). Owned by Quick Base.
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