ipp_quickbase_devkit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. data/LICENSE +87 -0
  2. data/README.rdoc +112 -0
  3. data/doc/QuickBaseClient.rb.htm +1896 -0
  4. data/doc/ReleaseNotes.txt +43 -0
  5. data/doc/qbc.makeCSVFile.qbc +4 -0
  6. data/doc/qbc.makeCSVFile.rb +4 -0
  7. data/doc/quickbase_adapter.rb.htm +399 -0
  8. data/examples/cookbookfiles/QuickBaseAPICookbook.html +2590 -0
  9. data/examples/cookbookfiles/addChangeRemoveUserRole.rb +21 -0
  10. data/examples/cookbookfiles/addOrEditRecord.rb +10 -0
  11. data/examples/cookbookfiles/application_object.rb +55 -0
  12. data/examples/cookbookfiles/applyRubyFormulas.rb +10 -0
  13. data/examples/cookbookfiles/average.rb +27 -0
  14. data/examples/cookbookfiles/backupApplication.rb +8 -0
  15. data/examples/cookbookfiles/cacheSchemas.rb +53 -0
  16. data/examples/cookbookfiles/calculateRunningTotals.rb +11 -0
  17. data/examples/cookbookfiles/copyrecords.rb +73 -0
  18. data/examples/cookbookfiles/count.rb +26 -0
  19. data/examples/cookbookfiles/createRecordNavigatorHTML.rb +42 -0
  20. data/examples/cookbookfiles/createReportDashboard.rb +35 -0
  21. data/examples/cookbookfiles/createTable.rb +12 -0
  22. data/examples/cookbookfiles/deviation.rb +25 -0
  23. data/examples/cookbookfiles/downloadCookbook.rb +97 -0
  24. data/examples/cookbookfiles/downloadFile.rb +10 -0
  25. data/examples/cookbookfiles/downloadFilesToFolder.rb +81 -0
  26. data/examples/cookbookfiles/downloadToTextFile.rb +64 -0
  27. data/examples/cookbookfiles/dumpSchema.rb +11 -0
  28. data/examples/cookbookfiles/duplicateRecord.rb +8 -0
  29. data/examples/cookbookfiles/dynamicMethods.rb +33 -0
  30. data/examples/cookbookfiles/editRecords.rb +15 -0
  31. data/examples/cookbookfiles/findJohnsLast10Records.rb +17 -0
  32. data/examples/cookbookfiles/findRubyRecords.rb +17 -0
  33. data/examples/cookbookfiles/formatCurrency.rb +24 -0
  34. data/examples/cookbookfiles/formatDate.rb +10 -0
  35. data/examples/cookbookfiles/formatDuration.rb +27 -0
  36. data/examples/cookbookfiles/formatPercent.rb +24 -0
  37. data/examples/cookbookfiles/getAllValuesForFields.rb +18 -0
  38. data/examples/cookbookfiles/getAppDTMInfo.rb +29 -0
  39. data/examples/cookbookfiles/getApplicationVariable.rb +5 -0
  40. data/examples/cookbookfiles/getChildTableDBID.rb +11 -0
  41. data/examples/cookbookfiles/getColumnListForReport.rb +6 -0
  42. data/examples/cookbookfiles/getFieldChoices.rb +13 -0
  43. data/examples/cookbookfiles/getFieldIDs.rb +6 -0
  44. data/examples/cookbookfiles/getFieldNames.rb +6 -0
  45. data/examples/cookbookfiles/getLastModTime.rb +8 -0
  46. data/examples/cookbookfiles/getLastRecModTime.rb +8 -0
  47. data/examples/cookbookfiles/getNumRecords.rb +8 -0
  48. data/examples/cookbookfiles/getNumTables.rb +4 -0
  49. data/examples/cookbookfiles/getRecord.rb +5 -0
  50. data/examples/cookbookfiles/getRecordDisplayURL.rb +13 -0
  51. data/examples/cookbookfiles/getRecordsAddedToday.rb +20 -0
  52. data/examples/cookbookfiles/getRecordsAsJSON.rb +6 -0
  53. data/examples/cookbookfiles/getReportNames.rb +25 -0
  54. data/examples/cookbookfiles/getRoleInfo.rb +48 -0
  55. data/examples/cookbookfiles/getServerStatus.rb +11 -0
  56. data/examples/cookbookfiles/getSortListForReport.rb +6 -0
  57. data/examples/cookbookfiles/getTableIDs.rb +6 -0
  58. data/examples/cookbookfiles/getTableName.rb +8 -0
  59. data/examples/cookbookfiles/getTableNames.rb +25 -0
  60. data/examples/cookbookfiles/getTimeCreated.rb +8 -0
  61. data/examples/cookbookfiles/getTimeInMilliseconds.rb +5 -0
  62. data/examples/cookbookfiles/getUserInfo.rb +26 -0
  63. data/examples/cookbookfiles/getUserRole.rb +15 -0
  64. data/examples/cookbookfiles/intranet.rb +101 -0
  65. data/examples/cookbookfiles/isAverageField.rb +17 -0
  66. data/examples/cookbookfiles/isDbidString.rb +8 -0
  67. data/examples/cookbookfiles/isTotalField.rb +16 -0
  68. data/examples/cookbookfiles/iterateDBPages.rb +8 -0
  69. data/examples/cookbookfiles/iterateFilteredRecords.rb +12 -0
  70. data/examples/cookbookfiles/iterateJoinRecords.rb +68 -0
  71. data/examples/cookbookfiles/iterateRecordInfos.rb +8 -0
  72. data/examples/cookbookfiles/iterateRecords.rb +23 -0
  73. data/examples/cookbookfiles/iterateSummaryRecords.rb +13 -0
  74. data/examples/cookbookfiles/iterateUnionRecords.rb +38 -0
  75. data/examples/cookbookfiles/listAccessibleApplications.rb +6 -0
  76. data/examples/cookbookfiles/logRequestAndResponseXML.rb +8 -0
  77. data/examples/cookbookfiles/lookupFieldPropertyByName.rb +62 -0
  78. data/examples/cookbookfiles/lookupFieldTypeByName.rb +10 -0
  79. data/examples/cookbookfiles/makeCSVFile.rb +4 -0
  80. data/examples/cookbookfiles/makeSlideShow.rb +42 -0
  81. data/examples/cookbookfiles/makerecs.rb +64 -0
  82. data/examples/cookbookfiles/max.rb +26 -0
  83. data/examples/cookbookfiles/min.rb +26 -0
  84. data/examples/cookbookfiles/percent.rb +29 -0
  85. data/examples/cookbookfiles/printChildElements.rb +54 -0
  86. data/examples/cookbookfiles/printNewRecords.rb +12 -0
  87. data/examples/cookbookfiles/processRESTRequest.rb +21 -0
  88. data/examples/cookbookfiles/provisionAndInviteNewUser.rb +13 -0
  89. data/examples/cookbookfiles/purgeRecords.rb +15 -0
  90. data/examples/cookbookfiles/quickbase_adapter.rb.htm +397 -0
  91. data/examples/cookbookfiles/quickbase_record_finder.zip +0 -0
  92. data/examples/cookbookfiles/recordAndFieldIterator.rb +24 -0
  93. data/examples/cookbookfiles/runImport.rb +9 -0
  94. data/examples/cookbookfiles/runQuickBaseTwitterConnector.rb +41 -0
  95. data/examples/cookbookfiles/sendToQuickBase.rb +33 -0
  96. data/examples/cookbookfiles/setDBvar.rb +6 -0
  97. data/examples/cookbookfiles/showRequestAndResponseXML.rb +8 -0
  98. data/examples/cookbookfiles/sqlQuery.rb +11 -0
  99. data/examples/cookbookfiles/stopOnError.rb +10 -0
  100. data/examples/cookbookfiles/sum.rb +26 -0
  101. data/examples/cookbookfiles/twitterFromQuickBase.rb +42 -0
  102. data/examples/cookbookfiles/twitterWithQuickBase.rb +36 -0
  103. data/examples/cookbookfiles/uploadCSVData.rb +20 -0
  104. data/examples/cookbookfiles/uploadExcelData.rb +22 -0
  105. data/examples/cookbookfiles/uploadFileEveryHour.rb +18 -0
  106. data/examples/cookbookfiles/uploadFileIntoNewRecord.rb +8 -0
  107. data/examples/cookbookfiles/uploadFilesFromFolder.exe +0 -0
  108. data/examples/cookbookfiles/uploadFilesFromFolder.rb +69 -0
  109. data/examples/cookbookfiles/useCompanyURL.rb +12 -0
  110. data/examples/cookbookfiles/userRoles.rb +49 -0
  111. data/examples/cookbookfiles/watchCommunityForum.rb +5 -0
  112. data/examples/cookbookfiles/wikifyTable.rb +29 -0
  113. data/examples/cookbookfiles/xmlShortcuts.rb +33 -0
  114. data/examples/pmp/app/controllers/application.rb +7 -0
  115. data/examples/pmp/app/controllers/contacts_controller.rb +8 -0
  116. data/examples/pmp/app/controllers/document_library_controller.rb +2 -0
  117. data/examples/pmp/app/controllers/issues_controller.rb +5 -0
  118. data/examples/pmp/app/controllers/projects_controller.rb +22 -0
  119. data/examples/pmp/app/controllers/resources_controller.rb +2 -0
  120. data/examples/pmp/app/controllers/tasks_controller.rb +13 -0
  121. data/examples/pmp/app/controllers/time_cards_controller.rb +5 -0
  122. data/examples/pmp/app/helpers/application_helper.rb +3 -0
  123. data/examples/pmp/app/helpers/contacts_helper.rb +2 -0
  124. data/examples/pmp/app/helpers/document_library_helper.rb +2 -0
  125. data/examples/pmp/app/helpers/issues_helper.rb +2 -0
  126. data/examples/pmp/app/helpers/projects_helper.rb +2 -0
  127. data/examples/pmp/app/helpers/resources_helper.rb +2 -0
  128. data/examples/pmp/app/helpers/tasks_helper.rb +2 -0
  129. data/examples/pmp/app/helpers/time_cards_helper.rb +2 -0
  130. data/examples/pmp/app/models/contacts.rb +26 -0
  131. data/examples/pmp/app/models/document_library.rb +2 -0
  132. data/examples/pmp/app/models/issues.rb +6 -0
  133. data/examples/pmp/app/models/projects.rb +26 -0
  134. data/examples/pmp/app/models/resources.rb +2 -0
  135. data/examples/pmp/app/models/tasks.rb +12 -0
  136. data/examples/pmp/app/models/time_cards.rb +7 -0
  137. data/examples/pmp/app/schemas/contacts.xml +1 -0
  138. data/examples/pmp/app/schemas/document_library.xml +1 -0
  139. data/examples/pmp/app/schemas/issues.xml +1 -0
  140. data/examples/pmp/app/schemas/pmp.xml +1 -0
  141. data/examples/pmp/app/schemas/projects.xml +1 -0
  142. data/examples/pmp/app/schemas/readme.txt +8 -0
  143. data/examples/pmp/app/schemas/resources.xml +1 -0
  144. data/examples/pmp/app/schemas/tasks.xml +1 -0
  145. data/examples/pmp/app/schemas/time_cards.xml +1 -0
  146. data/examples/pmp/app/views/contacts/companies.rhtml +31 -0
  147. data/examples/pmp/app/views/contacts/project_contacts.rhtml +31 -0
  148. data/examples/pmp/app/views/issues/filter_issues.rhtml +26 -0
  149. data/examples/pmp/app/views/layouts/application.rhtml +56 -0
  150. data/examples/pmp/app/views/projects/all_projects.rhtml +33 -0
  151. data/examples/pmp/app/views/projects/home.rhtml +11 -0
  152. data/examples/pmp/app/views/projects/my_open_projects.rhtml +27 -0
  153. data/examples/pmp/app/views/projects/open_projects.rhtml +44 -0
  154. data/examples/pmp/app/views/projects/project_sorted_by_company.rhtml +40 -0
  155. data/examples/pmp/app/views/projects/projects_sorted_by_priority.rhtml +30 -0
  156. data/examples/pmp/app/views/projects/updated_projects.rhtml +0 -0
  157. data/examples/pmp/app/views/tasks/all_tasks.rhtml +27 -0
  158. data/examples/pmp/app/views/tasks/search.rhtml +23 -0
  159. data/examples/pmp/app/views/tasks/search2.rhtml +23 -0
  160. data/examples/pmp/app/views/tasks/search3.rhtml +23 -0
  161. data/examples/pmp/app/views/time_cards/summary.rhtml +38 -0
  162. data/examples/pmp/config/boot.rb +45 -0
  163. data/examples/pmp/config/database.yml +30 -0
  164. data/examples/pmp/config/environment.rb +60 -0
  165. data/examples/pmp/config/environments/development.rb +21 -0
  166. data/examples/pmp/config/environments/production.rb +18 -0
  167. data/examples/pmp/config/environments/test.rb +19 -0
  168. data/examples/pmp/config/routes.rb +23 -0
  169. data/examples/pmp/db/migrate/001_create_projects.rb +10 -0
  170. data/examples/pmp/db/migrate/002_create_tasks.rb +10 -0
  171. data/examples/pmp/db/migrate/003_create_issues.rb +10 -0
  172. data/examples/pmp/db/migrate/004_create_document_libraries.rb +10 -0
  173. data/examples/pmp/db/migrate/005_create_resources.rb +10 -0
  174. data/examples/pmp/db/migrate/006_create_time_cards.rb +10 -0
  175. data/examples/pmp/db/migrate/007_create_contacts.rb +10 -0
  176. data/examples/pmp/public/404.html +30 -0
  177. data/examples/pmp/public/500.html +30 -0
  178. data/examples/pmp/public/app.index.html +277 -0
  179. data/examples/pmp/public/dispatch.cgi +10 -0
  180. data/examples/pmp/public/dispatch.fcgi +24 -0
  181. data/examples/pmp/public/dispatch.rb +10 -0
  182. data/examples/pmp/public/favicon.ico +0 -0
  183. data/examples/pmp/public/images/rails.png +0 -0
  184. data/examples/pmp/public/javascripts/application.js +2 -0
  185. data/examples/pmp/public/javascripts/controls.js +833 -0
  186. data/examples/pmp/public/javascripts/dragdrop.js +942 -0
  187. data/examples/pmp/public/javascripts/effects.js +1088 -0
  188. data/examples/pmp/public/javascripts/prototype.js +2515 -0
  189. data/examples/pmp/public/robots.txt +1 -0
  190. data/examples/pmp/test/fixtures/contacts.yml +5 -0
  191. data/examples/pmp/test/fixtures/document_libraries.yml +5 -0
  192. data/examples/pmp/test/fixtures/issues.yml +5 -0
  193. data/examples/pmp/test/fixtures/projects.yml +5 -0
  194. data/examples/pmp/test/fixtures/resources.yml +5 -0
  195. data/examples/pmp/test/fixtures/tasks.yml +5 -0
  196. data/examples/pmp/test/fixtures/time_cards.yml +5 -0
  197. data/examples/pmp/test/functional/contacts_controller_test.rb +18 -0
  198. data/examples/pmp/test/functional/document_library_controller_test.rb +18 -0
  199. data/examples/pmp/test/functional/issues_controller_test.rb +18 -0
  200. data/examples/pmp/test/functional/projects_controller_test.rb +18 -0
  201. data/examples/pmp/test/functional/resources_controller_test.rb +18 -0
  202. data/examples/pmp/test/functional/tasks_controller_test.rb +18 -0
  203. data/examples/pmp/test/functional/time_cards_controller_test.rb +18 -0
  204. data/examples/pmp/test/test_helper.rb +28 -0
  205. data/examples/pmp/test/unit/contacts_test.rb +10 -0
  206. data/examples/pmp/test/unit/document_library_test.rb +10 -0
  207. data/examples/pmp/test/unit/issues_test.rb +10 -0
  208. data/examples/pmp/test/unit/projects_test.rb +10 -0
  209. data/examples/pmp/test/unit/resources_test.rb +10 -0
  210. data/examples/pmp/test/unit/tasks_test.rb +10 -0
  211. data/examples/pmp/test/unit/time_cards_test.rb +10 -0
  212. data/lib/QuickBaseClient.rb +5054 -0
  213. data/lib/QuickBaseCommandLineClient.rb +401 -0
  214. data/lib/QuickBaseContactsAppBuilder.rb +419 -0
  215. data/lib/QuickBaseEmailer.rb +334 -0
  216. data/lib/QuickBaseEventNotifier.rb +592 -0
  217. data/lib/QuickBaseMisc.rb +96 -0
  218. data/lib/QuickBaseObjects.rb +566 -0
  219. data/lib/QuickBaseRSSGenerator.rb +286 -0
  220. data/lib/QuickBaseTextData.rb +545 -0
  221. data/lib/QuickBaseTwitterConnector.rb +300 -0
  222. data/lib/QuickBaseWebClient.rb +126 -0
  223. data/lib/WorkPlaceClient.rb +45 -0
  224. data/lib/qbc.makeCSVFile.qbc +4 -0
  225. data/lib/qbc.makeCSVFile.rb +17 -0
  226. data/lib/quickbase_adapter.rb +320 -0
  227. data/lib/runFieldEntryDialog.rb +151 -0
  228. data/lib/runOfflineFieldEntryDialog.rb +203 -0
  229. data/rakefile +100 -0
  230. data/test/run_tests.bat +7 -0
  231. data/test/spec_all_tests.rb +13 -0
  232. data/test/spec_smoke_tests.rb +58 -0
  233. data/test/spec_workplace_addrecord_test.rb +46 -0
  234. data/test/spec_workplace_base_test.rb +57 -0
  235. data/test/spec_workplace_editrecord_test.rb +38 -0
  236. data/test/spec_workplace_json_test.rb +38 -0
  237. data/test/spec_workplace_objects_test.rb +39 -0
  238. data/test/spec_workplace_smoke_tests.rb +45 -0
  239. metadata +353 -0
@@ -0,0 +1,2590 @@
1
+ <HTML><HEAD><TITLE>QuickBase API Cookbook v3</TITLE></HEAD><BODY><H1><a href="https://www.quickbase.com/db/bcdcajmrf">QuickBase API Cookbook v3</a></H1><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=116">Find QuickBase records by running a Windows batch file</a><h3>Keywords</h3>find records batch windows<br><h3>Problem:</h3>You want to find QuickBase records by typing a command at the Windows command prompt.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2
+
3
+ def find_and_display_records
4
+
5
+ puts &quot;Connecting to QuickBase...&quot;
6
+ qbc = QuickBase::Client.init({&quot;username&quot; =&gt; ARGV[0] ,&quot;password&quot; =&gt; ARGV[1],&quot;org&quot; =&gt; ARGV[2]})
7
+ qbc.cacheSchemas=true
8
+ #qbc.printRequestsAndResponses=true
9
+
10
+ puts &quot;Accessing table #{ARGV[3]}...&quot;
11
+ qbc.getSchema(ARGV[3])
12
+
13
+ search_value = &quot;&quot;
14
+ (5..ARGV.length-1).each{|index|search_value &lt;&lt; &quot;#{qbc.encodeXML(ARGV[index])} &quot;}
15
+ search_value.gsub!(&quot;'&quot;,&quot;\\'&quot;)
16
+ search_value.strip!
17
+
18
+ print &quot;Searching for '#{search_value}' ...\n&quot;
19
+
20
+ query = &quot;&quot;
21
+ field_ids = ARGV[4].split(/\./)
22
+ field_ids.each{|fid|
23
+ query &lt;&lt; &quot;{'#{fid}'.CT.'#{search_value}'}.OR.&quot;
24
+ }
25
+ query.slice!(query.length-4,4)
26
+
27
+ rids = qbc.getAllValuesForFieldsAsArray(ARGV[3],[&quot;3&quot;],query,nil,nil,&quot;3&quot;)
28
+
29
+ if rids and rids.length &gt; 0
30
+ if rids.length &gt; 1
31
+ puts &quot;Found #{rids.length} records. Retrieving HTML page...&quot;
32
+ qbc.cacheSchemas=true
33
+ html = qbc.genResultsTable(ARGV[3],query,qbc.getFieldIDs(qbc.dbid).join(&quot;.&quot;))
34
+ puts &quot;Creating quickbase_find_results.html...&quot;
35
+ File.open(&quot;quickbase_find_results.html&quot;,&quot;w&quot;){|f|f.write(html)}
36
+ puts &quot;Launching quickbase_find_results.html in browser...&quot;
37
+ system(&quot;start quickbase_find_results.html&quot;)
38
+ elsif rids.length == 1
39
+ puts &quot;Found one record. Displaying record for edit...&quot;
40
+ rid = rids[0][&quot;3&quot;]
41
+ puts &quot;Launching QuickBase in browser...&quot;
42
+ system(&quot;start https://www.quickbase.com/db/#{ARGV[3]}?a=er^&amp;rid=#{rid}^&amp;username=#{ARGV[0]}^&amp;password=#{ARGV[1]}&quot;)
43
+ end
44
+ else
45
+ puts &quot;Found no records. Launching QuickBase 'find' page...&quot;
46
+ system(&quot;start https://www.quickbase.com/db/#{ARGV[3]}?a=genadvfind^&amp;username=#{ARGV[0]}^&amp;password=#{ARGV[1]}&quot;)
47
+ end
48
+ end
49
+
50
+ if ARGV[5]
51
+ begin
52
+ find_and_display_records
53
+ rescue StandardError =&gt; error
54
+ puts &quot;\n\nAn error occurred while looking for QuickBase records: #{error}\n\n&quot;
55
+ end
56
+ else
57
+ puts &quot;\n\nUsage: quickbase_record_finder &lt;username&gt; &lt;password&gt; &lt;realm&gt; &lt;table_DBID&gt; &lt;field_IDs&gt; &lt;search_value&gt;&quot;
58
+ puts &quot;\ne.g: quickbase_record_finder fred.flintone@internet.com wilma www 8emtadvk 4.5.6 barney\n\n&quot;
59
+ end
60
+ </pre><br><h3>Discussion:</h3>Download and extract the attached quickbase_record_finder.zip into C:\.
61
+ Modify the qbrf.bat file and put it in your Windows PATH.
62
+ <br><h3>See Also:</h3><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=117">Dump the schema for a table into a file</a><h3>Keywords</h3>schema dump table<br><h3>Problem:</h3>You need to see the schema for a QuickBase table in a file rather than in QuickBase.<br><h3>Solution:</h3><pre>
63
+ require 'QuickBaseClient'
64
+
65
+ qbc = QuickBase::Client.new(ARGV[0],ARGV[1])
66
+ qbc.getSchema(ARGV[2])
67
+ File.open(&quot;#{ARGV[2]}.schema.xml&quot;,&quot;w&quot;){|f|f.write(qbc.qdbapi)}
68
+
69
+ # run this using 'ruby dumpSchema.rb &lt;username&gt; &lt;password&gt; &lt;table id&gt;'
70
+ # e.g. 'ruby dumpSchema.rb fred@flinstone wilma 8emtadvk'
71
+
72
+
73
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="dumpSchema.rb">dumpSchema.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=115">Retrieve records in JSON format</a><h3>Keywords</h3>JSON records<br><h3>Problem:</h3>You need records from QuickBase in JSON format, probably for displaying them on a web page.<br><h3>Solution:</h3><pre>require &quot;QuickBaseClient&quot;
74
+
75
+ # print the list of QuickBase formula functions in JSON format:
76
+
77
+ qbc=QuickBase::Client.new(ENV[&quot;quickbase_username&quot;],ENV[&quot;quickbase_password&quot;])
78
+ puts qbc.getAllValuesForFieldsAsPrettyJSON(&quot;6ewwzuuj&quot;,[&quot;Function Name&quot;])
79
+ </pre><br><h3>Discussion:</h3>getAllValuesForFieldsAsJSON runs the doQuery API call with all the parameters you need.
80
+ getAllValuesForFieldsAsPrettyJSON returns more human-readable JSON.
81
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getRecordsAsJSON.rb">getRecordsAsJSON.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=114">Use object-oriented programming to interact with QuickBase</a><h3>Keywords</h3>object oriented<br><h3>Problem:</h3>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.<br><h3>Solution:</h3><pre>require 'QuickBaseObjects'
82
+
83
+ qbob = QuickBase::Objects::Builder.new(&quot;username&quot;,&quot;password&quot;)
84
+
85
+ myApplication = qbob.application(&quot;My Application&quot;)
86
+
87
+ puts &quot;\n\nApplication name:\n&quot;
88
+ puts myApplication.name
89
+
90
+ puts &quot;\n\nApplication roles:\n&quot;
91
+ myApplication.roles.each_value{|role|puts &quot;name: #{role.name}, id: #{role.id}, access: #{role.access}&quot;}
92
+
93
+ puts &quot;\n\nApplication users:\n&quot;
94
+ myApplication.users.each_value{|user|puts &quot;id: #{user.id}&quot;}
95
+
96
+ puts &quot;\n\nApplication variables:\n&quot;
97
+ myApplication.variables.each_value{|variable|puts &quot;#{variable.name}: #{variable.value}&quot;}
98
+
99
+ puts &quot;\n\nValue of application variable 'TestVariable':\n&quot;
100
+ puts myApplication.vTestVariable
101
+
102
+ puts &quot;\n\nSet the value of application variable 'TestVariable':\n&quot;
103
+ myApplication.vTestVariable=&quot;New value for test variable&quot;
104
+
105
+ puts &quot;\n\nApplication pages:\n&quot;
106
+ myApplication.pages.each_value{|page|puts page.name}
107
+
108
+ puts &quot;\n\nDefault application page:\n&quot;
109
+ puts myApplication.pDefault_Dashboard.name
110
+
111
+ puts &quot;\n\nTables from My Application:\n&quot;
112
+ myApplication.tables.each_value{|table|puts table.name}
113
+
114
+ puts &quot;\n\nQueries from the Contacts table:\n&quot;
115
+ myApplication.tContacts.queries.each_value{|query|puts query.name}
116
+
117
+ puts &quot;\n\nProperties of the List All query from the Contacts table:\n&quot;
118
+ myApplication.tContacts.qList_All.properties.each_pair{|key,value|puts &quot;#{key}: #{value}&quot; }
119
+
120
+ puts &quot;\n\nNames from the List All query from the Contacts table:\n&quot;
121
+ records = myApplication.tContacts.qList_All.run
122
+ records.each{|record| puts record.fName}
123
+
124
+ puts &quot;\n\nColumns of the List All query from the Contacts table:\n&quot;
125
+ puts myApplication.tContacts.qList_All.qyclst
126
+
127
+ puts &quot;\n\nFields from the Contacts table:\n&quot;
128
+ myApplication.tContacts.fields.each_value{|field|puts field.name}
129
+
130
+ puts &quot;\n\nField ID of the Phone field in the Contacts table:\n&quot;
131
+ puts myApplication.tContacts.fPhone.id
132
+
133
+ puts &quot;\n\nName of field 7 from the Contacts table:\n&quot;
134
+ puts myApplication.tContacts.fields[&quot;7&quot;].name
135
+
136
+ </pre><br><h3>Discussion:</h3>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.
137
+ 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.
138
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="application_object.rb">application_object.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=113">Use dynamic nature of Ruby to simplify retrieving data from QuickBase</a><h3>Keywords</h3>dynamic ruby <br><h3>Problem:</h3>Ruby has some wonderful dynamic features which can simplify your script code. If you know precisely what data you want to retrieve, you can use 'hard-coded' dbid, record id, field id, etc in your code.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
139
+
140
+ qbc = QuickBase::Client.new
141
+
142
+ puts &quot;\n\nDescription of QuickBase API Cookbook application:\n\n&quot;
143
+
144
+ puts qbc.bcdcajmrf.xml_desc
145
+
146
+ puts &quot;\n\nIngredients from the QuickBase API Cookbook:\n\n&quot;
147
+
148
+ qbc.bcdcajmrh.qid_1.printChildElements(qbc.records)
149
+
150
+ puts &quot;\n\nValue of field 6 from record 24105 in table 8emtadvk:\n\n&quot;
151
+
152
+ puts qbc.dbid_8emtadvk.rid_24105.fid_6 # prints 'Ruby wrapper for QuickBase HTTP API'
153
+ </pre><br><h3>Discussion:</h3>The following dynamic methods are available:
154
+
155
+ dbid_?
156
+ rid_?
157
+ qid_?
158
+ fid_?
159
+ pageid_?
160
+ userid_?
161
+ vid_?
162
+ import_?
163
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="dynamicMethods.rb">dynamicMethods.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=112">Use shortcuts to get values from XML returned from QuickBase</a><h3>Keywords</h3>xml shortcut<br><h3>Problem:</h3>You want to extract information that may only be available in the XML returned from QuickBase, but don't want to parse the XML.<br><h3>Solution:</h3><pre>require 'QuickbaseClient'
164
+
165
+ qbc = QuickBase::Client.new
166
+
167
+ qbc.getSchema(&quot;bbqm84dzy&quot;)
168
+ puts &quot;\n\nSchema information for QuickBase Community Forum application:\n\n&quot;
169
+
170
+ puts &quot;Application dbid: #{qbc.xml_app_id}&quot;
171
+ puts &quot;Application description: #{qbc.xml_desc}&quot;
172
+ puts &quot;XML for list of child tables: #{qbc.xml_chdbids}&quot;
173
+ puts &quot;Last child table dbid: #{qbc.xml_chdbid}&quot;
174
+ puts &quot;Application variables: #{qbc.xml_variables}&quot;
175
+
176
+ qbc.getSchema(&quot;8emtadvk&quot;)
177
+ puts &quot;\n\nSchema information for QuickBase Community Forum Messages table:\n\n&quot;
178
+
179
+ puts &quot;Table name: #{qbc.xml_table.elements['name'].text}&quot;
180
+ puts &quot;Field 1 name: #{qbc.xml_field('1').label}&quot;
181
+ puts &quot;Field 2 name: #{qbc.xml_field('id','2').label}&quot;
182
+ puts &quot;Field 3 reuired?: #{qbc.xml_field('3').required == 1}&quot;
183
+ puts &quot;Query 2 criteria: #{qbc.xml_query('2').qycrit}&quot;
184
+ puts &quot;XML for Query 1: #{qbc.xml_query('1')}&quot;
185
+ puts &quot;Name for Query 1: #{qbc.xml_query('1').qyname}&quot;
186
+ puts &quot;Next Record #ID will be: #{qbc.xml_next_record_id}&quot;
187
+
188
+ qbc.getRecordInfo(&quot;8emtadvk&quot;,&quot;24105&quot;)
189
+ puts &quot;\n\nInfo from Record 24105:\n\n&quot;
190
+
191
+ puts &quot;Number of fields in record: #{qbc.xml_num_fields}&quot;
192
+ puts &quot;XML of last field: #{qbc.xml_field}&quot;
193
+ puts &quot;ID of last field: #{qbc.xml_field.fid}&quot;
194
+ puts &quot;Name of last field: #{qbc.xml_field.elements['name'].text}&quot;
195
+ </pre><br><h3>Discussion:</h3>Thanks to the wonders of the Ruby programming language, this can be done using the Ruby Wrapper for QuickBase by using a method in the format 'xml_?' - i.e. the method starts with xml_ and the XML element you are looking for is next, e.g. xml_desc.
196
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="xmlShortcuts.rb">xmlShortcuts.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=107">Add a new QuickBase user and invite him to an application</a><h3>Keywords</h3>provision add invite user<br><h3>Problem:</h3>You need to add a new QuickBase user and invite the user to an existing application, via email.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
197
+
198
+ # Add a new user to QuickBase and email the user an invitation to an application
199
+
200
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;,&quot;My Fantastic Application&quot;)
201
+
202
+ # Assume &quot;11&quot; is the id of the Participant role in &quot;My Fantastic Application&quot;
203
+
204
+ qbc._provisionUser(&quot;11&quot;, &quot;fred_flintstone@internet.com&quot;, &quot;fred&quot;, &quot;flintstone&quot;)
205
+
206
+ qbc._sendInvitation(qbc.userid)
207
+
208
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="provisionAndInviteNewUser.rb">provisionAndInviteNewUser.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=111">Add/Change/Remove users from Roles</a><h3>Keywords</h3>add change remove user role<br><h3>Problem:</h3>You want to use the API to add people to a role, change their role, and remove them from a role.<br><h3>Solution:</h3><pre>
209
+ require 'QuickBaseClient'
210
+
211
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
212
+
213
+ # get Fred's QuickBase user info
214
+ qbc.getUserInfo(&quot;fred_flintstone@internet.com&quot;)
215
+
216
+ fredsUserID = qbc.userid.dup
217
+
218
+ # Assume &quot;10&quot; is the id of the Viewer role in the application with the &quot;bbqm84dzy&quot; id
219
+ qbc.addUserToRole( &quot;bbqm84dzy&quot;, fredsUserID, &quot;10&quot; )
220
+
221
+ # Assume &quot;11&quot; is the id of the Participant role in the application with the &quot;bbqm84dzy&quot; id
222
+ qbc.changeUserRole( &quot;bbqm84dzy&quot;, fredsUserID, &quot;10&quot;, &quot;11&quot; )
223
+
224
+ # Remove Fred from the Participant Role
225
+ qbc.removeUserFromRole( &quot;bbqm84dzy&quot;, fredsUserID, &quot;11&quot; )
226
+
227
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="addChangeRemoveUserRole.rb">addChangeRemoveUserRole.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=110">Run a pre-defined Import via the API</a><h3>Keywords</h3>import <br><h3>Problem:</h3>You have defined an Import routine for a table, by going into QuickBase in a brrowser, and want to run the import automatically via the QuickBase API. <br><h3>Solution:</h3><pre>
228
+ require 'QuickBaseClient'
229
+
230
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
231
+
232
+ # run pre-defined Import #3 into table bcdcajmrf
233
+
234
+ qbc.runImport(&quot;bcdcajmrf&quot;,&quot;3&quot;)
235
+
236
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="runImport.rb">runImport.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=109">Get a list of the users and their roles in an application</a><h3>Keywords</h3>users roles <br><h3>Problem:</h3>You need a list of the users with access to an application, and what roles they are in.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
237
+
238
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;,&quot;My Application&quot;)
239
+
240
+ qbc._userRoles() { |user|
241
+ qbc.printChildElements( user )
242
+ }
243
+
244
+ =begin
245
+
246
+ Approximate output of above script:
247
+
248
+ user (id=3453444.csw ):
249
+ name = Fred Flintstone
250
+ lastAccess = 1241207132457
251
+ firstName = Fred
252
+ lastName = Flintstone
253
+ roles :
254
+ role (id=18 ):
255
+ name = Participant with Modify Own
256
+ access (id=3 ) = Basic Access
257
+ user (id=345434444.bpw5 ):
258
+ name = Wilma Flintstone
259
+ lastAccess = 1240232570603
260
+ firstName = Wilma
261
+ lastName = Flintstone
262
+ roles :
263
+ role (id=18 ):
264
+ name = Participant with Modify Own
265
+ access (id=3 ) = Basic Access
266
+ user (id=24343444.bh ):
267
+ name = Top Sales
268
+ lastAccess = 1236700941307
269
+ firstName = Top
270
+ lastName = Sales
271
+ roles :
272
+ role (id=18 ):
273
+ name = Participant with Modify Own
274
+ access (id=3 ) = Basic Access
275
+ user (id=111.ckbs ):
276
+ name = Anonymous
277
+ roles :
278
+ role (id=11 ):
279
+ name = Participant
280
+ access (id=3 ) = Basic Access
281
+ =end
282
+
283
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="userRoles.rb">userRoles.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=108">Set the value of an application variable</a><h3>Keywords</h3>application variable set<br><h3>Problem:</h3>You need to set the value of an application variable using the QuickBase API<br><h3>Solution:</h3><pre>
284
+ require 'QuickBaseClient'
285
+
286
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;,&quot;My Appointments&quot;)
287
+
288
+ qbc._setDBvar(&quot;HourlyRate&quot;,&quot;350.00&quot;)
289
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="setDBvar.rb">setDBvar.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=106">Get the role of a particular user in a particular application</a><h3>Keywords</h3>user role application<br><h3>Problem:</h3>You need to know the Role of a particular user in a particular application.<br><h3>Solution:</h3><pre>
290
+ require 'QuickBaseClient'
291
+
292
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
293
+
294
+ qbc.getUserInfo( &quot;fred_flinstone@internet.com&quot;)
295
+
296
+ qbc.getUserRole(&quot;bbqm84dzy&quot;,qbc.userid)
297
+
298
+ puts &quot;user id : #{qbc.userid}&quot;
299
+ puts &quot;user name: #{qbc.username}&quot;
300
+ puts &quot;role id : #{qbc.roleid}&quot;
301
+ puts &quot;role name: #{qbc.rolename}&quot;
302
+ puts &quot;access id: #{qbc.accessid}&quot;
303
+ puts &quot;access : #{qbc.access}&quot;
304
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getUserRole.rb">getUserRole.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=105">Get date/time information about an application</a><h3>Keywords</h3>date time <br><h3>Problem:</h3>You need to know the time that requests and changes were last made to an application, and the next time that an API request will be allowed to be made to the application.<br><h3>Solution:</h3><pre>
305
+
306
+ require 'QuickBaseClient'
307
+
308
+ qbc = QuickBase::Client.new
309
+
310
+ puts &quot;\n\nDate/time information about the QuickBase Community Forum:\n\n&quot;
311
+
312
+ qbc.getAppDTMInfo(&quot;bbqm84dzy&quot;)
313
+
314
+ puts &quot;Time of request : #{qbc.formatFieldValue(qbc.requestTime.text,'timestamp')}&quot;
315
+ puts &quot;Time next request allowed : #{qbc.formatFieldValue(qbc.requestNextAllowedTime.text,'timestamp')}&quot;
316
+ puts &quot;Time application last modified : #{qbc.formatFieldValue(qbc.lastModifiedTime,'timestamp')}&quot;
317
+ puts &quot;Time any record last modified : #{qbc.formatFieldValue(qbc.lastRecModTime,'timestamp')}&quot;
318
+
319
+
320
+ =begin
321
+
322
+ Output of the above script:
323
+
324
+ Date/time information about the QuickBase Community Forum:
325
+
326
+ Time of request : 05-03-2009 03:52 PM
327
+ Time next request allowed : 05-03-2009 03:52 PM
328
+ Time application last modified : 03-26-2009 01:55 PM
329
+ Time any record last modified : 05-02-2009 10:10 AM
330
+
331
+ =end
332
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getAppDTMInfo.rb">getAppDTMInfo.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=104">Add a table to an application</a><h3>Keywords</h3>add create table<br><h3>Problem:</h3>You need to add a table to an existing application using the QuickBase API<br><h3>Solution:</h3><pre>
333
+ require 'QuickBaseClient'
334
+
335
+ # Add an Authors table to a Books application
336
+
337
+ qbc = QuickBase::Client.new( &quot;username&quot;,&quot;password&quot;,&quot;Books&quot;)
338
+
339
+ qbc.createTable(&quot;Authors&quot;)
340
+
341
+ qbc._addField(&quot;Name&quot;, &quot;text&quot;)
342
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="createTable.rb">createTable.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=103">Get informaton about a specific QuickBase user</a><h3>Keywords</h3>user info email<br><h3>Problem:</h3>You know a particular QuickBase user's email address and need to get other information about that user from QuickBase.<br><h3>Solution:</h3><pre>
343
+ require 'QuickBaseClient'
344
+
345
+ def displayUserInfo( qbc, emailAddress = nil)
346
+
347
+ qbc.getUserInfo emailAddress
348
+
349
+ puts &quot;name : #{qbc.name}&quot;
350
+ puts &quot;first name : #{qbc.firstName}&quot;
351
+ puts &quot;last name : #{qbc.lastName}&quot;
352
+ puts &quot;login : #{qbc.login}&quot;
353
+ puts &quot;email : #{qbc.email}&quot;
354
+ puts &quot;screen name : #{qbc.screenName}&quot;
355
+ puts &quot;externalAuth: #{qbc.externalAuth}&quot;
356
+ puts &quot;user id : #{qbc.userid}&quot;
357
+
358
+ end
359
+
360
+
361
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
362
+
363
+ puts &quot;\n\nInformation in QuickBase about the person running this script:\n\n&quot;
364
+ displayUserInfo(qbc)
365
+
366
+ puts &quot;\n\nInformation in QuickBase about fred_flinstone@internet.com:\n\n&quot;
367
+ displayUserInfo(qbc, &quot;fred_flinstone@internet.com&quot;)
368
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getUserInfo.rb">getUserInfo.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=102">Get the list of Roles in an application</a><h3>Keywords</h3>role list <br><h3>Problem:</h3>You need the list of Roles in an application in order to add someone to a role<br><h3>Solution:</h3><pre>
369
+ require 'QuickBaseClient'
370
+
371
+ qbc = QuickBase::Client.new
372
+
373
+ puts &quot;\nRoles in the QuickBase Community Forum\n\n&quot;
374
+
375
+ qbc.getRoleInfo(&quot;bbqm84dzy&quot;) { |role|
376
+ puts &quot;id: #{role.attributes['id']}&quot;
377
+ puts &quot;name: #{role.elements['name'].text}&quot;
378
+ puts &quot;access id: #{role.elements['access'].attributes['id']}&quot;
379
+ puts &quot;access name: #{role.elements['access'].text}&quot;
380
+ puts &quot;=============================&quot;
381
+ }
382
+
383
+ =begin
384
+
385
+ Output of the above script:
386
+
387
+ Roles in the QuickBase Community Forum
388
+
389
+ id: 10
390
+ name: Viewer
391
+ access id: 3
392
+ access name: Basic Access
393
+ =============================
394
+ id: 11
395
+ name: Participant
396
+ access id: 3
397
+ access name: Basic Access
398
+ =============================
399
+ id: 12
400
+ name: Administrator
401
+ access id: 1
402
+ access name: Administrator
403
+ =============================
404
+ id: 17
405
+ name: Product Manager
406
+ access id: 1
407
+ access name: Administrator
408
+ =============================
409
+ id: 18
410
+ name: Participant with Modify Own
411
+ access id: 3
412
+ access name: Basic Access
413
+ =============================
414
+
415
+ =end
416
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getRoleInfo.rb">getRoleInfo.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=5">Create an RSS feed using data from multiple QuickBase tables</a><h3>Keywords</h3>RSS feed<br><h3>Problem:</h3>You want data from multiple QuickBase tables to be viewable by an RSS reader.<br><h3>Solution:</h3><pre>The Ruby wrapper includes a script called QuickBaseRSSGenerator.rb. It includes an example of generating RSS from both the QuickBase Community Forum and the QuickBase KnowledgeBase. The example can be run by typing:
417
+
418
+ ruby QuickBaseRSSGenerator.rb username password
419
+
420
+ This puts a file called QuickBaseInfoRSS.xml in your current folder. This can be read by an RSS reader.
421
+
422
+ Generating RSS from your own tables will just be a matter of modifying a copy of this code from QuickBaseRSSGenerator.rb:
423
+
424
+ #-----------------------------------------------------------------------------------
425
+ # The following test code generates RSS text from recently modified
426
+ # records in the QuickBase Community Forum and KnowledgeBase.
427
+ #-----------------------------------------------------------------------------------
428
+ def test( username, password )
429
+
430
+ qbc = QuickBase::Client.new( username, password )
431
+ qbRSSgen = QuickBase::RSSGenerator.new( qbc )
432
+
433
+ qbRSSgen.unSorted
434
+
435
+ qbRSSgen.setTitle( &quot;QuickBase Forum/KnowledgeBase RSS&quot; )
436
+ qbRSSgen.setLink( &quot;main&quot; )
437
+ qbRSSgen.setDescription( &quot;RSS view of QuickBase Community Forum and KnowledgeBase&quot; )
438
+
439
+ qbRSSgen.addTable(&quot;8emtadvk&quot;, &quot;Community Forum&quot;, { &quot;title&quot; =&gt; &quot;6&quot;, &quot;description&quot; =&gt; &quot;10&quot; }, nil, nil, nil, 75 )
440
+ qbRSSgen.addTable( &quot;6mztyxu8&quot;, &quot;KnowledgeBase&quot;, { &quot;title&quot; =&gt; &quot;5&quot;, &quot;description&quot; =&gt; &quot;6&quot; }, nil, nil, nil, 50 )
441
+
442
+ rssText = qbRSSgen.generateRSStext
443
+
444
+ File.open( &quot;QuickBaseInfoRSS.xml&quot;, &quot;w&quot; ) { |file| file.write( rssText ) }
445
+ print &quot;\nPlease view QuickBaseInfoRSS.xml in an RSS reader, a browser or an XML editor.\n&quot;
446
+
447
+ end
448
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=60">Make a CSV file from the data in a table</a><h3>Keywords</h3>CSV file download<br><h3>Problem:</h3>You need QuickBase data in a CSV file but don't want to use the 'manual' Export process in QuickBase.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
449
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;My QuickBase Database&quot; )
450
+ qbc.makeSVFile( &quot;MyCSVFile.csv&quot; )
451
+ qbc.signOut
452
+
453
+ </pre><br><h3>Discussion:</h3>If you find yourself manually exporting from the same table to the to the same CSV file over and over, this will save you a lot of time.
454
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="makeCSVFile.rb">makeCSVFile.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=1">Download the QuickBase API Cookbook recipes to your local drive</a><h3>Keywords</h3>Download<br><h3>Problem:</h3>You want a local copy of the recipes in the QuickBase API Cookbook.<br><h3>Solution:</h3><pre>Please see the File Attachment - this script is 90 lines long and a bit too much to display here. The script creates a directory called 'cookbookfiles' that contains QuickBaseAPICookbook.html and downloaded file attachments.</pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="downloadCookbook.rb">downloadCookbook.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=101">Get the table IDs of the child tables of an application</a><h3>Keywords</h3>table id child application<br><h3>Problem:</h3>You need to loop through the tables of an application using a list of the table ids.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
455
+
456
+ puts &quot;\nThe QuickBase Support Center has these child tables:\n\n&quot;
457
+ puts QuickBase::Client.new.getTableIDs(&quot;9kaw8phg&quot;).join(&quot;\n&quot;)
458
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getTableIDs.rb">getTableIDs.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=100">Lookup a field property</a><h3>Keywords</h3>lookup field property<br><h3>Problem:</h3>Before processing records in some way, you need to know something about the definition of a particular field in QuickBase.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
459
+
460
+ qbc = QuickBase::Client.new
461
+
462
+ qbc.getSchema(&quot;8emtadvk&quot;)
463
+ showTimeInDateModified = qbc.lookupFieldPropertyByName(&quot;Date Modified&quot;,&quot;display_time&quot;) == &quot;1&quot; ? &quot;is&quot; : &quot;is not&quot;
464
+
465
+ puts &quot;\nFor the Date Modified field in the QuickBase Community Forum, the time of day #{showTimeInDateModified} displayed.\n&quot;
466
+
467
+ puts &quot;\nThe field properties you can lookup are: \n\n&quot;
468
+ puts qbc.validFieldProperties.join(&quot;\n&quot;)
469
+
470
+ =begin
471
+
472
+ The above code prints -
473
+
474
+
475
+ For the Date Modified field in the QuickBase Community Forum, the time of day is displayed.
476
+
477
+ The field properties you can lookup are:
478
+
479
+ allowHTML
480
+ allow_new_choices
481
+ appears_by_default
482
+ append_only
483
+ blank_is_zero
484
+ bold
485
+ carrychoices
486
+ comma_start
487
+ cover_text
488
+ decimal_places
489
+ default_kind
490
+ default_today
491
+ display_dow
492
+ display_month
493
+ display_relative
494
+ display_time
495
+ display_today
496
+ display_user
497
+ display_zone
498
+ does_average
499
+ does_total
500
+ doesdatacopy
501
+ exact
502
+ find_enabled
503
+ foreignkey
504
+ label
505
+ nowrap
506
+ num_lines
507
+ required
508
+ sort_as_given
509
+ unique
510
+ use_new_window
511
+ target_dbid
512
+ target_dbname
513
+ target_fieldname
514
+ target_fid
515
+ source_fieldname
516
+ source_fid
517
+
518
+ =end
519
+
520
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="lookupFieldPropertyByName.rb">lookupFieldPropertyByName.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=99">Copy images from web pages to QuickBase records</a><h3>Keywords</h3>copy image web <br><h3>Problem:</h3>You want a fast way to copy images from web pages to QuickBase records<br><h3>Solution:</h3><pre>Follow the steps to create a Windows Desktop icon for copying local files to QuickBase - https://www.quickbase.com/db/bcdcajmrg?a=dr&amp;r=db&amp;rl=ixf .
521
+
522
+ In Firefox, drag an image directly from a web page onto your desktop, then drag it onto the icon for uploading files into QuickBase. The image file will be uploaded into a QuickBase application with the same name as the folder for your Desktop. After it has been uploaded, delete the image file from your Desktop.
523
+
524
+
525
+
526
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=98">Create links to other records inside HTML text fields </a><h3>Keywords</h3>link wiki tag url<br><h3>Problem:</h3>You have a table with an HTML text field and you want to create links to other records in the HTML.<br><h3>Solution:</h3><pre>require 'QuickBaseclient'
527
+
528
+ qbc = QuickBase::Client.new(ENV[&quot;quickbase_username&quot;],ENV[&quot;quickbase_password&quot;])
529
+
530
+ dbid = &quot;bdeapkrmj&quot;
531
+ baseURL = &quot;https://www.quickbase.com/db/#{dbid}?a=dr&amp;rid=&quot;
532
+ links = {}
533
+
534
+ # collect all the possible links in the table using the values in a particular text field
535
+ qbc.iterateRecords(dbid,[&quot;Record ID#&quot;,&quot;tag&quot;]){|record|
536
+ if record[&quot;tag&quot;] and record[&quot;tag&quot;].length &gt; 0
537
+ links[record[&quot;tag&quot;]] = &quot;&lt;a href='#{baseURL}#{record[&quot;Record ID#&quot;]}&amp;rl=rfe'&gt;#{record['tag']}&lt;/a&gt;&quot;
538
+ end
539
+ }
540
+
541
+ # loop through all the values in a particular HTML text field and insert links to other records
542
+ if links.length &gt; 0
543
+ qbc.iterateRecords(dbid,[&quot;Record ID#&quot;,&quot;text&quot;]){|record|
544
+ newText = record[&quot;text&quot;].dup
545
+ newText.gsub!(&quot;
546
+ &quot;,&quot;&quot;)
547
+ links.each{|tag,url|
548
+ newText.gsub!(url,tag) # remove existing link so we don't duplicate it
549
+ newText.gsub!(tag,url)
550
+ }
551
+ qbc.clearFieldValuePairList
552
+ qbc.addFieldValuePair(&quot;text&quot;,nil,nil,newText)
553
+ qbc.editRecord(dbid,record[&quot;Record ID#&quot;],qbc.fvlist)
554
+ }
555
+ end
556
+ </pre><br><h3>Discussion:</h3>This example uses the all the values in the 'tag' field to create links to other records in all the 'text' fields. The 'tag' field requires unique values but doesn't have to be the key field for the table.
557
+
558
+
559
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="wikifyTable.rb">wikifyTable.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=97">Send a file to QuickBase by dragging it onto a Windows desktop icon</a><h3>Keywords</h3>drag drop windows desktop<br><h3>Problem:</h3>You want a fast way to send files from Windows into QuickBase records.<br><h3>Solution:</h3><pre>Follow all the steps listed in the 'Send To ' recipe - https://www.quickbase.com/db/bcdcajmrg?a=dr&amp;r=cu&amp;rl=iuh .
560
+
561
+ After that, copy the 'QuickBase' shortcut from the Windows SendTo folder onto your Windows Desktop. You can then drag and drop files onto the 'QuickBase' desktop icon.
562
+
563
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=95">Get table and record values using simple REST requests</a><h3>Keywords</h3>REST request<br><h3>Problem:</h3>You want to get information about tables and fields using simple REST syntax.
564
+ <br><h3>Solution:</h3><pre>require 'QuickBaseClient'
565
+
566
+ qbc = QuickBase::Client.new(ENV[&quot;quickbase_username&quot;],ENV[&quot;quickbase_password&quot;])
567
+
568
+ puts &quot;\nTable id for QuickBase Community Forum:\n\n&quot;
569
+ puts qbc.processRESTRequest(&quot;QuickBase Community Forum&quot;)
570
+
571
+ puts &quot;\nName of Community Forum table:\n\n&quot;
572
+ puts qbc.processRESTRequest(&quot;8emtadvk&quot;)
573
+
574
+ puts &quot;\nCommunity Forum record for Ruby wrapper:\n\n&quot;
575
+ puts qbc.processRESTRequest(&quot;8emtadvk/24105&quot;)
576
+
577
+ puts &quot;\nFunction Names listed in QuickBase Support Center:\n\n&quot;
578
+ puts qbc.processRESTRequest(&quot;6ewwzuuj/Function Name&quot;)
579
+
580
+ puts &quot;\nRecipe 93 from the QuickBase API Cookbook:\n\n&quot;
581
+ puts qbc.processRESTRequest(&quot;QuickBase API Cookbook v3/Recipes/93&quot;)
582
+
583
+ puts &quot;\nGet the title of Recipe 93 from the QuickBase API Cookbook:\n\n&quot;
584
+ puts qbc.processRESTRequest(&quot;QuickBase API Cookbook v3/Recipes/93/Title&quot;)
585
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="processRESTRequest.rb">processRESTRequest.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=96">Exchange messages automatically between QuickBase and Twitter</a><h3>Keywords</h3>twitter message automatic<br><h3>Problem:</h3>You want to connect QuickBase and Twitter so that messages are automatically sent between the two applications, you want to send automated replies from QuickBase to Twitter, and you want to perform simple QuickBase queries from Twitter.
586
+ <br><h3>Solution:</h3><pre>require 'QuickBaseTwitterConnector'
587
+
588
+ QuickBase::TwitterConnector.new
589
+
590
+ =begin
591
+
592
+ This is a example of what you will see.
593
+ The Twitter Connector will run in a loop, checking for new information every few minutes.
594
+ Probably the most useful feature of this Connector is the ability to send two types of
595
+ automated response, static text and the results from simple REST queries.
596
+ Remember that Twitter only accepts the first 140 characters of text.
597
+
598
+ The Connector automatically creates a QuickBase application using your QuickBase
599
+ username and your Twitter username.
600
+
601
+ ----------------------------------------------------------------------------------
602
+
603
+ Please enter the Quickbase username to use for this session: fred_flintstone@internet.com
604
+ Please enter the Quickbase password to use for this session: wilma
605
+ Please enter the Twitter username to use for this session: fred_flintstone
606
+ Please enter the Twitter password to use for this session: wilma
607
+
608
+
609
+ Please enter a number to select the connection type:
610
+
611
+ 1 - Send Twitter messages to QuickBase.
612
+ 2 - Send QuickBase messages to Twitter.
613
+ 3 - Exchange messages between QuickBase and Twitter.
614
+ 4 - Send automated replies from QuickBase to Twitter.
615
+ 5 - All the above.
616
+
617
+ 5
618
+
619
+
620
+ Getting 'friends' Twitter Status since Fri, 28 Mar 2008 13:47:24 -0700.
621
+ Getting Direct Messages from Twitter since Fri, 28 Mar 2008 13:47:24 -0700.
622
+ Sending messages from QuickBase to Twitter added since Fri, 28 Mar 2008 13:47:24 -0700.
623
+ Getting Direct Messages from Twitter since Fri, 28 Mar 2008 13:47:24 -0700.
624
+ Automated Direct Message sent to wilma_flintstone: what's for dinner?: rex ribs
625
+
626
+ =end
627
+ </pre><br><h3>Discussion:</h3>The best way to understand how the TwitterConnector works is by reading the source code of the QuickBaseTwitterConnector.rb file which is part of the Ruby wrapper.
628
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="runQuickBaseTwitterConnector.rb">runQuickBaseTwitterConnector.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=93">Get a list of records with human-readable field values</a><h3>Keywords</h3>printable readable<br><h3>Problem:</h3>The API returns certain field types, such as dates and users, as raw data rather than formatted the same way as they appear in QuickBase.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
629
+
630
+ puts &quot;\n\nQuickBase Formula Functions Reference:\n\n&quot;
631
+
632
+ QuickBase::Client.new.iterateRecordInfos(&quot;6ewwzuuj&quot;){|ri|
633
+ puts &quot;------------------------------&quot;
634
+ ri.each{|field,value| puts &quot;#{field}: #{value}\n&quot;}
635
+ }
636
+ </pre><br><h3>Discussion:</h3>NOTE: iterateRecordInfos() can be much slower that iterateRecords() because every record triggers a separate API request to QuickBase.
637
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="iterateRecordInfos.rb">iterateRecordInfos.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=94">Get a list of field IDs for a table</a><h3>Keywords</h3>field id table list<br><h3>Problem:</h3>You need a list of the Field IDs for all the fields in a QuickBase table.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
638
+
639
+ puts &quot;\n\nThe field IDs for the QuickBase Community Forum are : #{QuickBase::Client.new.getFieldIDs(&quot;8emtadvk&quot;).join(&quot;,&quot;)}\n\n&quot;
640
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getFieldIDs.rb">getFieldIDs.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=92">Get the time in milliseconds, for comparison with QuickBase record timestamps</a><h3>Keywords</h3>timestamp milliseconds<br><h3>Problem:</h3>QuickBase stores 'Date Created' and 'Date Modified' as milliseconds and returns them to API clients in milliseconds. To compare those fields to the current time or another time, you need to format the time in milliseconds.
641
+ <br><h3>Solution:</h3><pre>require 'QuickBaseMisc'
642
+
643
+ puts &quot;\n\nThe time now in milliseconds is #{QuickBase::Misc.time_in_milliseconds}.&quot;
644
+ puts &quot;\nThe time in milliseconds at the beginning of today was #{QuickBase::Misc.time_in_milliseconds(Date.today)}.&quot;
645
+ puts &quot;\nThe time in milliseconds at this time tomorrow will be #{QuickBase::Misc.time_in_milliseconds(DateTime.now + 1)}.&quot;
646
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getTimeInMilliseconds.rb">getTimeInMilliseconds.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=91">Get the name of a QuickBase table from its id</a><h3>Keywords</h3>id table name<br><h3>Problem:</h3>You know the dbid of a QuickBase table and want to use that to get the name of the table.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
647
+
648
+ qbc = QuickBase::Client.new
649
+
650
+ puts &quot;The name of the table for dbid 'bbqm84dzy' is '#{qbc.getTableName('bbqm84dzy')}'.&quot;
651
+
652
+ # The above code prints -
653
+ # The name of the table for dbid 'bbqm84dzy' is 'QuickBase Community Forum'.
654
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getTableName.rb">getTableName.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=90">Get the number of tables in a QuickBase application</a><h3>Keywords</h3>number tables<br><h3>Problem:</h3>You want to know the number of tables in a particular QuickBase application.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
655
+
656
+ qbc = QuickBase::Client.new
657
+ puts &quot;There are #{qbc.getNumTables(&quot;bbtt9cjr6&quot;)} tables in the QuickBase Application Library.&quot;
658
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getNumTables.rb">getNumTables.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=89">Test whether a string is in the format of a QuickBase database ID (dbid)</a><h3>Keywords</h3>dbid id string<br><h3>Problem:</h3>Before attempting to access a QuickBase table using the API, you want to test whether the string representing a table id (dbid) is in the right format. The string should be a Base 32 number using the base 32 scheme used by QuickBase.<br><h3>Solution:</h3><pre>
659
+ require 'QuickBaseMisc'
660
+
661
+ print &quot;\n\nEnter a string: &quot;
662
+ string = gets.chop
663
+
664
+ puts &quot;\n\n'#{string}' is #{QuickBase::Misc.isDbidString?(string) ? '' : 'not'} a valid QuickBase table id string.\n\n&quot;
665
+
666
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="isDbidString.rb">isDbidString.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=88">Get messages from QuickBase to send to Twitter</a><h3>Keywords</h3>twitter message<br><h3>Problem:</h3>You want to enter messages in QuickBase and send them from there to Twitter.<br><h3>Solution:</h3><pre>require 'rubygems'
667
+ gem 'twitter4r', '&gt;=0.3.0'
668
+ require 'twitter'
669
+
670
+ require 'QuickBaseClient'
671
+
672
+ print &quot;Please enter your QuickBase username: &quot;
673
+ quickbase_username = gets.chop
674
+ print &quot;Please enter your QuickBase password: &quot;
675
+ quickbase_password = gets.chop
676
+ qbc = QuickBase::Client.new(quickbase_username,quickbase_password)
677
+
678
+ dbid = qbc.findDBByName(&quot;Twitter messages (#{quickbase_username})&quot; )
679
+ if dbid.nil?
680
+ dbid = qbc.createDatabase(&quot;Twitter messages (#{quickbase_username})&quot;, &quot;This is a list of messages from Twitter.&quot;)
681
+ qbc.addField(dbid,&quot;Twitter_Screen_Name&quot;, &quot;text&quot;)
682
+ qbc.addField(dbid,&quot;Twitter_Message&quot;, &quot;text&quot;)
683
+ else
684
+
685
+ messagesToMoveToTwitter = []
686
+ qbc.iterateRecords(dbid,[&quot;Record ID#&quot;,&quot;Twitter_Screen_Name&quot;,&quot;Twitter_Message&quot;]){|record|
687
+ p record
688
+ if record[&quot;Twitter_Screen_Name&quot;].nil? or record[&quot;Twitter_Screen_Name&quot;] == &quot;&quot; and record[&quot;Twitter_Message&quot;] and record[&quot;Twitter_Message&quot;] != &quot;&quot;
689
+ messagesToMoveToTwitter &lt;&lt; record[&quot;Twitter_Message&quot;]
690
+ qbc.deleteRecord(dbid,record[&quot;Record ID#&quot;])
691
+ end
692
+ }
693
+
694
+ if messagesToMoveToTwitter.length &gt; 0
695
+ print &quot;Please enter your Twitter username: &quot;
696
+ twitter_username = gets.chop
697
+ print &quot;Please enter your Twitter password: &quot;
698
+ twitter_password = gets.chop
699
+ twitter_client = Twitter::Client.new(:login =&gt; twitter_username, :password =&gt; twitter_password )
700
+
701
+ messagesToMoveToTwitter.each {|message|
702
+ Twitter::Status.create(:text =&gt; message,:client =&gt; twitter_client)
703
+ }
704
+
705
+ end
706
+
707
+ end
708
+ </pre><br><h3>Discussion:</h3>This solution depends on the twitter4r Ruby API for Twitter.
709
+ It looks for messages in QuickBase that have no 'sender', sends them to Twitter, then removes them from QuickBase.
710
+ The messages will just be updates to your Twitter status.
711
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="twitterFromQuickBase.rb">twitterFromQuickBase.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, twitter4r<br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=87">Get Twitter messages into QuickBase</a><h3>Keywords</h3>Twitter<br><h3>Problem:</h3>You want to send messages from Twitter to QuickBase.<br><h3>Solution:</h3><pre>require 'rubygems'
712
+ gem 'twitter4r', '&gt;=0.3.0'
713
+ require 'twitter'
714
+
715
+ # ----------------------------------------------------------------------
716
+ require 'QuickBaseClient'
717
+
718
+ print &quot;Please enter your QuickBase username: &quot;
719
+ quickbase_username = gets.chop
720
+
721
+ print &quot;Please enter your QuickBase password: &quot;
722
+ quickbase_password = gets.chop
723
+
724
+ qbc = QuickBase::Client.new(quickbase_username,quickbase_password)
725
+ dbid = qbc.findDBByName(&quot;Twitter messages (#{quickbase_username})&quot; )
726
+ if dbid.nil?
727
+ dbid = qbc.createDatabase(&quot;Twitter messages (#{quickbase_username})&quot;, &quot;This is a list of messages from Twitter.&quot;)
728
+ qbc.addField(dbid,&quot;Twitter_Screen_Name&quot;, &quot;text&quot;)
729
+ qbc.addField(dbid,&quot;Twitter_Message&quot;, &quot;text&quot;)
730
+ end
731
+
732
+ # ----------------------------------------------------------------------
733
+ print &quot;Please enter your Twitter username: &quot;
734
+ twitter_username = gets.chop
735
+
736
+ print &quot;Please enter your Twitter password: &quot;
737
+ twitter_password = gets.chop
738
+
739
+ twitter_client = Twitter::Client.new(:login =&gt; twitter_username, :password =&gt; twitter_password )
740
+ timeline = twitter_client.timeline_for(:public) do |status|
741
+ qbc.clearFieldValuePairList
742
+ qbc.addFieldValuePair(&quot;Twitter_Screen_Name&quot;,nil,nil,status.user.screen_name)
743
+ qbc.addFieldValuePair(&quot;Twitter_Message&quot;,nil,nil,status.text)
744
+ qbc.addRecord(dbid,qbc.fvlist)
745
+ end
746
+ </pre><br><h3>Discussion:</h3>This script requires the twitter4r Ruby API for Twitter.
747
+ It sends the last 20 public Twitter messages to QuickBase.
748
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="twitterWithQuickBase.rb">twitterWithQuickBase.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, twitter4r<br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=86">Make a slideshow in QuickBase from a folder of picture files</a><h3>Keywords</h3>slide show slideshow picture folder<br><h3>Problem:</h3>You want to use QuickBase to display a sequence of web pages containing 'slides' containing the picture files from a folder on your local computer.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
749
+ require 'QuickBaseMisc'
750
+
751
+ username = ARGV[0] || ENV[&quot;quickbase_username&quot;]
752
+ password = ARGV[1] || ENV[&quot;quickbase_password&quot;]
753
+
754
+ qbc = QuickBase::Client.new(username,password)
755
+
756
+ cwd = Dir.pwd.gsub('/','\\')
757
+
758
+ dbid = qbc.findDBByName(cwd)
759
+ if dbid.nil?
760
+ dbid = qbc.createDatabase(cwd,&quot;#{username}'s slide show from #{cwd}.&quot;)
761
+ qbc.addField(dbid,&quot;Picture&quot;,&quot;file&quot;)
762
+ qbc.addField(dbid,&quot;HtmlPage&quot;,&quot;file&quot;)
763
+ else
764
+ qbc.getSchema(dbid)
765
+ dbid = qbc.lookupChdbid(cwd.dup)
766
+ qbc.getSchema(dbid)
767
+ end
768
+ pictureFieldID = QuickBase::Misc.decimalToBase32(6)
769
+ htmlPageFieldID = QuickBase::Misc.decimalToBase32(7)
770
+ Dir.foreach(cwd){|file|
771
+ next unless [&quot;.jpeg&quot;, &quot;.jpg&quot;,&quot;.gif&quot;,&quot;.bmp&quot;,&quot;.png&quot;].include?(file.downcase[file.rindex('.'),file.length])
772
+ renamedFile = file.dup
773
+ renamedFile.gsub!(&quot;&amp;&quot;,&quot;And&quot;)
774
+ renamedFile.gsub!(&quot;'&quot;,&quot; &quot;)
775
+ if renamedFile != file
776
+ File.rename(file,renamedFile)
777
+ end
778
+ puts &quot;Uploading #{renamedFile}&quot;
779
+ rid, updateid = qbc.uploadFile(dbid, renamedFile.dup, &quot;Picture&quot;)
780
+ thisRid = QuickBase::Misc.decimalToBase32(rid.to_i)
781
+ prevRid = QuickBase::Misc.decimalToBase32(rid.to_i-1)
782
+ nextRid = QuickBase::Misc.decimalToBase32(rid.to_i+1)
783
+ pictureURL = &quot;https://www.quickbase.com/up/#{dbid}/g/r#{thisRid}/e#{pictureFieldID}/va/#{renamedFile.dup}&quot;
784
+ prevHtmlURL = &quot;https://www.quickbase.com/up/#{dbid}/g/r#{prevRid}/e#{htmlPageFieldID}/va/slide.html&quot;
785
+ nextHtmlURL = &quot;https://www.quickbase.com/up/#{dbid}/g/r#{nextRid}/e#{htmlPageFieldID}/va/slide.html&quot;
786
+ html = &quot;&lt;center&gt;&lt;img src=\&quot;#{pictureURL}\&quot; /&gt;&lt;br&gt;#{renamedFile.dup}&lt;b&gt;#{}&lt;/b&gt;&lt;hr&gt;&lt;a href=\&quot;#{prevHtmlURL}\&quot;&gt;Previous&lt;/a&gt; &lt;a href=\&quot;#{nextHtmlURL}\&quot;&gt;Next&lt;/a&gt;&lt;/center&gt;&quot;
787
+ File.open(&quot;slide.html&quot;,&quot;w&quot;){|f|f.write(html)}
788
+ qbc.updateFile(dbid,rid,&quot;slide.html&quot;,&quot;HtmlPage&quot;)
789
+ }
790
+ </pre><br><h3>Discussion:</h3>Note: This script must be run from the folder containing the picture files, and you must supply your QuickBase username and password on the command line or in environment variables &quot;quickbase_username&quot; and &quot;quickbase_password&quot;.
791
+
792
+ The script will create or update a QuickBase application with the same name as the folder your are in on your local computer. To begin the slideshow, click on the &quot;slide.html&quot; file in the first QuickBase record in the database.
793
+
794
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="makeSlideShow.rb">makeSlideShow.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=85">Use company.quickbase.com instead of www.quickbase.com in all API calls</a><h3>Keywords</h3>company org<br><h3>Problem:</h3>You are using the Enterprise version of QuickBase and all your applications are in (e.g.) mycompany.quickbase.com instead of www.quickbase.com. Your API calls must also connect to mycompany.quickbase.com instead of www.quickbase.com.<br><h3>Solution:</h3><pre>
795
+ require 'QuickBaseClient'
796
+
797
+ #There are two ways to set the URL for your company
798
+
799
+ # 1)
800
+ qbc1 = QuickBase::Client.new( &quot;fred_flinstone@internet.com&quot;, &quot;wilma&quot;, nil, true, false, false, false, &quot;mycompany&quot; )
801
+
802
+ # 2)
803
+ qbc2 = QuickBase::Client.new( &quot;fred_flinstone@internet.com&quot;, &quot;wilma&quot;)
804
+ qbc2.setqbhost( true, &quot;mycompany&quot; )
805
+
806
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="useCompanyURL.rb">useCompanyURL.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=84">Display a 'running total' column in a regular Table report</a><h3>Keywords</h3>running total table report<br><h3>Problem:</h3>QuickBase Summary reports can display running totals, but regular 'Table' reports only show totals when you group the reports by numeric fields. <br><h3>Solution:</h3><pre>require 'QuickBaseClient'
807
+
808
+ qbc = QuickBase::Client.new(ENV[&quot;quickbase_username&quot;],ENV[&quot;quickbase_password&quot;])
809
+
810
+ runningTotal = 0
811
+ qbc.iterateRecords(&quot;bdcvpsxpy&quot;,qbc.getFieldNames(&quot;bdcvpsxpy&quot;),nil,nil,&quot;List All by Date Created&quot;){|record|
812
+ runningTotal += record['number'].to_i
813
+ qbc.clearFieldValuePairList
814
+ qbc.addFieldValuePair(&quot;running total&quot;,nil,nil,runningTotal.to_s)
815
+ qbc.editRecord(&quot;bdcvpsxpy&quot;,record['Record ID#'],qbc.fvlist)
816
+ }
817
+ </pre><br><h3>Discussion:</h3>This solution does not require grouping. Note that the value in the 'running total' field depends on the sort order of the Report you use. If users view a Report with a different sort order, the 'running total' values will not be correct until you run this script using that Report.
818
+
819
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="calculateRunningTotals.rb">calculateRunningTotals.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=83">Use Ruby code in a 'formula' field</a><h3>Keywords</h3>ruby formula<br><h3>Problem:</h3>You want to use Ruby code to calculate field values rather than a regular QuickBase formula field.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
820
+
821
+ qbc = QuickBase::Client.new(ENV[&quot;quickbase_username&quot;],ENV[&quot;quickbase_password&quot;])
822
+ qbc.iterateRecords(&quot;bdcvpsxpy&quot;,qbc.getFieldNames(&quot;bdcvpsxpy&quot;)){|record|
823
+ nameAndNumber = eval(record['ruby formula 1']) || &quot;&lt;name and number&gt;&quot;
824
+ qbc.clearFieldValuePairList
825
+ qbc.addFieldValuePair(&quot;name+number&quot;,nil,nil,nameAndNumber)
826
+ qbc.editRecord(&quot;bdcvpsxpy&quot;, record['Record ID#'],qbc.fvlist)
827
+ }
828
+
829
+ </pre><br><h3>Discussion:</h3>This example works by treating the value of a text field as Ruby code, and setting the value of another field in each record by evaluating the Ruby code. The Ruby code can access other fields in the same record, or from other records, or it can use data that is not in QuickBase at all.
830
+ Use default values and field-level permissions to turn regular text fields into a 'ruby formula' fields.
831
+ Also note how this example gets the QuickBase username and password from environment variables.
832
+ An interesting thing to explore with this idea is the possibility of having a different formula for every record.
833
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="applyRubyFormulas.rb">applyRubyFormulas.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=82">Send a file to QuickBase from the Windows 'Send To' menu</a><h3>Keywords</h3>send Windows explorer right-click<br><h3>Problem:</h3>You want to upload files from Windows folders by right-clicking them and selecting 'Send To, QuickBase' .<br><h3>Solution:</h3><pre>1. Create a sendToQuickBase.bat file with the following text:
834
+
835
+ ruby sendToQuickBase.rb %1
836
+ pause
837
+
838
+ 2. Put the attached sendToQuickBase.rb file next to your sendToQuickBase.bat file
839
+ 3. Right-click your Windows Start button and select Explore
840
+ 4. Find the 'SendTo' folder
841
+ 5. In the SendTo folder, create a shortcut that points to you sendToQuickBase.bat file
842
+ 5. Give the name 'QuickBase' to the shortcut.
843
+ 6. Test out your shortcut by right-clicking any Windows file and selecting 'QuickBase' from the 'Send To' menu. The file you selected will appear in a QuickBase application with the same name as the folder that contains the file. For example, if you select the file c:\temp\test.txt, the file will go into a QuickBase application called c:\temp.
844
+
845
+
846
+
847
+ =======================================
848
+ require 'QuickBaseClient'
849
+
850
+ if ARGV[0] and File.exist?(ARGV[0]) and ARGV[0].rindex(&quot;\\&quot;)
851
+ username = ARGV[1] || ENV[&quot;quickbase_username&quot;]
852
+ password = ARGV[2] || ENV[&quot;quickbase_password&quot;]
853
+ if username.nil?
854
+ print &quot;Please enter your QuickBase user name: &quot;
855
+ username = gets.chop
856
+ end
857
+ if password.nil?
858
+ print &quot;Please enter your QuickBase password: &quot;
859
+ password = gets.chop
860
+ end
861
+ qbc = QuickBase::Client.new(username, password)
862
+ folder = ARGV[0][0,ARGV[0].rindex(&quot;\\&quot;)]
863
+ file = ARGV[0][ARGV[0].rindex(&quot;\\&quot;)+1,ARGV[0].length]
864
+ dbid = qbc.findDBByName(folder)
865
+ if dbid.nil?
866
+ dbid = qbc.createDatabase(folder,&quot;Files uploaded from #{folder}&quot;)
867
+ qbc.addField(dbid, &quot;Description&quot;,&quot;text&quot;)
868
+ qbc.addField(dbid, &quot;File Attachment&quot;,&quot;file&quot;)
869
+ else
870
+ qbc.getSchema(dbid)
871
+ dbid = qbc.lookupChdbid(folder.dup)
872
+ end
873
+ Dir.chdir(folder)
874
+ qbc.uploadFile(dbid,file.dup,&quot;File Attachment&quot;)
875
+ else
876
+ puts &quot;\n\nusage: ruby sendToQuickBase.rb &lt;filepath&gt; [username] [password]&quot;
877
+ puts &quot;\ne.g. ruby sendToQuickBase.rb c:\temp\mySpecialFile&quot;
878
+ puts &quot;\nYou can omit your username and password if they are in environment&quot;
879
+ puts &quot;variables 'quickbase_username' and 'quickbase_password'.\n\n&quot;
880
+ end
881
+ </pre><br><h3>Discussion:</h3>To distrubute this to users easily, use the rubyscript2exe utility to make a sendToQuickBase.exe file, and have the users create a SendTo shortcut to sendToQuickBase.exe using the steps above.<br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="sendToQuickBase.rb">sendToQuickBase.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, rubyscript2exe<br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=81">QuickBase Instant Messenger</a><h3>Keywords</h3>instant messenger<br><h3>Problem:</h3>You want an instant messenger that saves its messages into QuickBase.<br><h3>Solution:</h3><pre>See the 'qbm - QuickBase Messenger' application at https://www.quickbase.com/db/bb4xcmxni .
882
+ This is an example of how to create a cross-platform interactive desktop application that saves its data into QuickBase.
883
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=80">Display a report and its form on one web page</a><h3>Keywords</h3>report form page<br><h3>Problem:</h3>When you click on a View link in a QuickBase report, the report goes off the screen and is replaced by the form for viewing the record. It would be nice to be able to keep the record links on the screen while the form is displayed.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
884
+ require 'QuickBaseMisc'
885
+
886
+ qbc = QuickBase::Client.new
887
+
888
+ i = 0
889
+ recordViewLinks = &quot;&quot;
890
+ qbc.iterateRecords(&quot;8emtadvk&quot;,[&quot;Message ID#&quot;,&quot;Subject&quot;]){|msg|
891
+ if i &lt; 15
892
+ r = QuickBase::Misc.decimalToBase32(msg['Message ID#'])
893
+ recordViewLinks &lt;&lt; &quot;&lt;a href=\&quot;https://www.quickbase.com/db/8emtadvk?a=dr&amp;r=#{r}\&quot; target=\&quot;RecordContainer\&quot;&gt;#{msg['Subject']}&lt;/a&gt;&lt;br&gt;&quot;
894
+ end
895
+ i += 1
896
+ }
897
+
898
+ html = &lt;&lt;EndHTML
899
+
900
+ &lt;html&gt;
901
+ &lt;head&gt;
902
+ &lt;style type=&quot;text/css&quot;&gt;
903
+ td { white-space: nowrap; vertical-align: top }
904
+ &lt;/style&gt;
905
+ &lt;/head&gt;
906
+ &lt;body&gt;
907
+ &lt;table border=&quot;1&quot; &gt;
908
+ &lt;tr&gt;&lt;td&gt;&lt;b&gt;Community Forum Records&lt;/b&gt;&lt;td&gt;&lt;td&gt;&lt;/tr&gt;
909
+ &lt;tr&gt;
910
+ &lt;td&gt;
911
+ #{recordViewLinks}
912
+ &lt;/td&gt;
913
+ &lt;td&gt;
914
+ &lt;iframe name=&quot;RecordContainer&quot; Width=&quot;800&quot; Height=&quot;650&quot; /&gt;
915
+ &lt;/td&gt;
916
+ &lt;/tr&gt;
917
+ &lt;/table&gt;
918
+ &lt;/body&gt;
919
+ &lt;/html&gt;
920
+
921
+ EndHTML
922
+
923
+ File.open(&quot;QuickBaseCommunityForumRecordViewer.html&quot;,&quot;w&quot;){|f|f.write(html)}
924
+ </pre><br><h3>Discussion:</h3>This code creates a QuickBaseCommunityForumRecordViewer.html file with links to view the latest 15 Community Forum records.
925
+ There is a sample output file here - https://www.quickbase.com/up/bcdcajmrj/g/rc/ei/va/QuickBaseCommunityForumRecordViewer.html
926
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="createRecordNavigatorHTML.rb">createRecordNavigatorHTML.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=79">Get the record display URL for a record</a><h3>Keywords</h3>display url record<br><h3>Problem:</h3>The URL for Viewing a record in QuickBase uses a base-32 number for the Record ID#, instead of the regular decimal number.<br><h3>Solution:</h3><pre>require 'QuickBaseMisc'
927
+
928
+ r = QuickBase::Misc.decimalToBase32(24105)
929
+ puts &quot;&lt;a href=\&quot;https://www.quickbase.com/db/8emtadvk?a=dr&amp;r=#{r}\&quot;&gt;Ruby API home page&lt;/a&gt;&quot;
930
+
931
+ =begin
932
+
933
+ The above code prints this HTML link -
934
+
935
+ &lt;a href=&quot;https://www.quickbase.com/db/8emtadvk?a=dr&amp;r=ztj&quot;&gt;Ruby API home page&lt;/a&gt;
936
+
937
+ =end
938
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getRecordDisplayURL.rb">getRecordDisplayURL.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=78">Make a web page with report links fixed on the left side</a><h3>Keywords</h3>report links fixed html page<br><h3>Problem:</h3>QuickBase Dashboards let you click on Report links on the left hand side of the screen, but clicking a report displays the report and the Reports links go off the screen. The example code builds an HTML page with report links on the left that stay on the screen when you click them. This can be a significant navigation improvement for some applications.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
939
+
940
+ qbc = QuickBase::Client.new
941
+
942
+ reportsHTML = &quot;&quot;
943
+ reportNames = qbc.getReportNames(&quot;8emtadvk&quot;)
944
+ reportNames.each{|reportName|
945
+ report = qbc.lookupQueryByName(reportName)
946
+ reportID = report.attributes[&quot;id&quot;]
947
+ reportsHTML &lt;&lt; &quot;&lt;a href=\&quot;https://www.quickbase.com/db/8emtadvk?a=q&amp;qid=#{reportID}\&quot; target=\&quot;ReportContainer\&quot; &gt;#{reportName}&lt;/a&gt;&lt;BR&gt;&quot;
948
+ }
949
+
950
+ html = &quot;&lt;html&gt;&quot;
951
+ html &lt;&lt; &quot;&lt;head&gt;&quot;
952
+ html &lt;&lt; &quot;&lt;style type=\&quot;text/css\&quot;&gt;&quot;
953
+ html &lt;&lt; &quot;td { white-space: nowrap; vertical-align: top }&quot;
954
+ html &lt;&lt; &quot;&lt;/style&gt;&quot;
955
+ html &lt;&lt; &quot;&lt;/head&gt;&quot;
956
+ html &lt;&lt; &quot;&lt;body&gt;&quot;
957
+ html &lt;&lt; &quot;&lt;table border=\&quot;1\&quot; &gt;&quot;
958
+ html &lt;&lt; &quot;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Community Forum Reports&lt;/b&gt;&lt;td&gt;&lt;td&gt;&lt;/tr&gt;&quot;
959
+ html &lt;&lt; &quot;&lt;tr&gt;&quot;
960
+ html &lt;&lt; &quot;&lt;td&gt;&lt;b&gt;&quot;
961
+ html &lt;&lt; reportsHTML
962
+ html &lt;&lt; &quot;&lt;/b&gt;&lt;/td&gt;&quot;
963
+ html &lt;&lt; &quot;&lt;td&gt;&quot;
964
+ html &lt;&lt; &quot;&lt;iframe name=\&quot;ReportContainer\&quot; Width=\&quot;700\&quot; Height=\&quot;800\&quot; /&gt;&quot;
965
+ html &lt;&lt; &quot;&lt;/td&gt;&quot;
966
+ html &lt;&lt; &quot;&lt;/tr&gt;&quot;
967
+ html &lt;&lt; &quot;&lt;/table&gt;&quot;
968
+ html &lt;&lt; &quot;&lt;/body&gt;&quot;
969
+ html &lt;&lt; &quot;&lt;/html&gt;&quot;
970
+
971
+ File.open(&quot;QuickBaseCommunityForumReports.html&quot;,&quot;w&quot;){|f|f.write(html)}
972
+ </pre><br><h3>Discussion:</h3>This example makes a web page for the QuickBase Community forum. You can open the QuickBaseCommunityForumReports.html file to see the results. The file you generate can be uploaded manually or automatically into QuickBase to create your own kind of Dashboard.
973
+
974
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="createReportDashboard.rb">createReportDashboard.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=77">Get a list of the sort fields used in a report</a><h3>Keywords</h3>sort field report<br><h3>Problem:</h3>You need a list of the sort fields used in a QuickBase report.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
975
+
976
+ qbc = QuickBase::Client.new
977
+ qbc.getSchema(&quot;8emtadvk&quot;)
978
+ puts &quot;Sort fields for QuickBase Community Forum 'List Changes' report: #{qbc.getSortListForQuery(nil,'List Changes')}&quot;
979
+ puts &quot;Sort fields for QuickBase Community Forum 'List Changes' report: #{qbc.getSortListForQuery('2',nil)}&quot;
980
+ </pre><br><h3>Discussion:</h3>This is useful when you want to use the doQuery() API call and sort the results using the same sort field as an existing QuickBase report.
981
+
982
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getSortListForReport.rb">getSortListForReport.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=76">Get a list of the columns used in a report</a><h3>Keywords</h3>column list report<br><h3>Problem:</h3>You need a list of the columns used in a QuickBase report.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
983
+
984
+ qbc = QuickBase::Client.new
985
+ qbc.getSchema(&quot;8emtadvk&quot;)
986
+ puts &quot;Columns for QuickBase Community Forum 'List all' report: #{qbc.getColumnListForQuery(nil,'List All')}&quot;
987
+ puts &quot;Columns for QuickBase Community Forum 'List all' report: #{qbc.getColumnListForQuery(&quot;1&quot;,nil)}&quot;
988
+ </pre><br><h3>Discussion:</h3>This is useful when you want to retrieve all the columns for a report when using the doQuery() API call.
989
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getColumnListForReport.rb">getColumnListForReport.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=75">Determine whether a field has an Average in reports</a><h3>Keywords</h3>field total<br><h3>Problem:</h3>You need to know whether a field in QuickBase has an Average at the bottom of reports in QuickBase.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
990
+
991
+ qbc = QuickBase::Client.new
992
+
993
+ qbc.getSchema(&quot;93htvp8y&quot;)
994
+
995
+ if qbc.isAverageField?(&quot;Subject&quot;)
996
+ puts &quot;The 'Subject' field in the QuickBase Community Forum has an Average at the bottom of reports.&quot;
997
+ else
998
+ puts &quot;The 'Subject' field in the QuickBase Community Forum does not have a Average at the bottom of reports.&quot;
999
+ end
1000
+
1001
+ if qbc.isAverageField?(&quot;# of Posts&quot;)
1002
+ puts &quot;The '# of Posts' field in the QuickBase Community Forum has a Average at the bottom of reports.&quot;
1003
+ else
1004
+ puts &quot;The '# of Posts' field in the QuickBase Community Forum does not have a Average at the bottom of reports.&quot;
1005
+ end
1006
+ </pre><br><h3>Discussion:</h3>This is useful if you want to duplicate a QuickBase report in an HTML page or some other format outside QuickBase.
1007
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="isAverageField.rb">isAverageField.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=74">Determine whether a field has a Total in reports</a><h3>Keywords</h3>field total<br><h3>Problem:</h3>You need to know whether a field in QuickBase has a Total at the bottom of reports in QuickBase.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1008
+
1009
+ qbc = QuickBase::Client.new
1010
+
1011
+ qbc.getSchema(&quot;8emtadvk&quot;)
1012
+ if qbc.isTotalField?(&quot;Subject&quot;)
1013
+ puts &quot;The 'Subject' field in the QuickBase Community Forum has a Total at the bottom of reports.&quot;
1014
+ else
1015
+ puts &quot;The 'Subject' field in the QuickBase Community Forum does not have a Total at the bottom of reports.&quot;
1016
+ end
1017
+
1018
+ if qbc.isTotalField?(&quot;# of Posts&quot;)
1019
+ puts &quot;The '# of Posts' field in the QuickBase Community Forum has a Total at the bottom of reports.&quot;
1020
+ else
1021
+ puts &quot;The '# of Posts' field in the QuickBase Community Forum does not have a Total at the bottom of reports.&quot;
1022
+ end
1023
+ </pre><br><h3>Discussion:</h3>This is useful if you want to duplicate a QuickBase report in an HTML page or some other format outside QuickBase.
1024
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="isTotalField.rb">isTotalField.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=73">Improve the speed of multiple API requests</a><h3>Keywords</h3>speed performance<br><h3>Problem:</h3>If your script makes a lot of API calls for different tables, the performance (i.e. speed) may not be enough.
1025
+ <br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1026
+
1027
+ qbc = QuickBase::Client.new
1028
+
1029
+ # get the schema for the QuickBase Community Forum
1030
+ firstTime=true
1031
+ 2.times {
1032
+
1033
+ totalTime = Time.now
1034
+
1035
+ 8.times {
1036
+ getSchemaTime = Time.now
1037
+ qbc.getSchema(&quot;bbqm84dzy&quot;)
1038
+ puts &quot;getSchema took #{Time.now-getSchemaTime} seconds&quot;
1039
+ }
1040
+
1041
+ puts &quot;\nTotal time: #{Time.now-totalTime} seconds&quot;
1042
+
1043
+ qbc.signOut
1044
+ qbc = QuickBase::Client.new
1045
+ qbc.cacheSchemas = true
1046
+ puts &quot;Caching schema...&quot; if firstTime
1047
+ firstTime = false
1048
+ }
1049
+
1050
+ =begin
1051
+
1052
+ Sample output of the above script:-
1053
+
1054
+ getSchema took 1.438 seconds
1055
+ getSchema took 0.515 seconds
1056
+ getSchema took 0.5 seconds
1057
+ getSchema took 0.485 seconds
1058
+ getSchema took 0.515 seconds
1059
+ getSchema took 0.532 seconds
1060
+ getSchema took 0.484 seconds
1061
+ getSchema took 0.5 seconds
1062
+
1063
+ Total time: 4.969 seconds
1064
+ Caching schema...
1065
+ getSchema took 0.515 seconds
1066
+ getSchema took 0.016 seconds
1067
+ getSchema took 0.015 seconds
1068
+ getSchema took 0.0 seconds
1069
+ getSchema took 0.016 seconds
1070
+ getSchema took 0.0 seconds
1071
+ getSchema took 0.016 seconds
1072
+ getSchema took 0.031 seconds
1073
+
1074
+ Total time: 0.609 seconds
1075
+
1076
+ =end
1077
+
1078
+ </pre><br><h3>Discussion:</h3>'cacheSchemas' is one of the things you can do to improve performance. Reducing the number of API requests will always improve performance.
1079
+
1080
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="cacheSchemas.rb">cacheSchemas.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=72">Get the list of reports for a table</a><h3>Keywords</h3>list reports queries<br><h3>Problem:</h3>You need a list of the reports for a table.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1081
+
1082
+ qbc = QuickBase::Client.new
1083
+
1084
+ # list the reports from the Formula Functions Reference table in the QuickBase Support Center
1085
+ puts qbc.getReportNames(&quot;6ewwzuuj&quot;)
1086
+
1087
+ =begin
1088
+
1089
+ The above code prints the list below:-
1090
+
1091
+ All Functions
1092
+ All Functions and Operators
1093
+ Boolean Functions
1094
+ Formula Export View
1095
+ gsa_formula functions ref
1096
+ List All
1097
+ List Changes
1098
+ Number Functions
1099
+ Operators - Binary
1100
+ Operators - Unary
1101
+ Text Functions
1102
+ Time and Date Functions
1103
+
1104
+ =end
1105
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getReportNames.rb">getReportNames.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=71">Get the status of the QuickBase server</a><h3>Keywords</h3>server status<br><h3>Problem:</h3>You are curious about the status of the QuickBase server.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1106
+
1107
+ qbc = QuickBase::Client.new
1108
+ serverStatus = qbc.getServerStatus
1109
+
1110
+ puts &quot;\nversion: #{serverStatus['version']}&quot;
1111
+ puts &quot;users: #{serverStatus['users']}&quot;
1112
+ puts &quot;groups: #{serverStatus['groups']}&quot;
1113
+ puts &quot;databases: #{serverStatus['databases']}&quot;
1114
+ puts &quot;uptime: #{serverStatus['uptime']}&quot;
1115
+ puts &quot;updays: #{serverStatus['updays']}&quot;
1116
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getServerStatus.rb">getServerStatus.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=70">List the pages in an application</a><h3>Keywords</h3>list pages page application<br><h3>Problem:</h3>You need a list of the pages in an application.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1117
+
1118
+ qbc = QuickBase::Client.new
1119
+
1120
+ # List the Pages from the QuickBase Support Center
1121
+ qbc.iterateDBPages(&quot;9kaw8phg&quot;){|page|
1122
+ puts &quot;Page: #{page['name']}, Type: #{page['type']}, ID: #{page['id']}\n&quot;
1123
+ }
1124
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="iterateDBPages.rb">iterateDBPages.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=68">Edit a record, or add one if necessary</a><h3>Keywords</h3>add edit record<br><h3>Problem:</h3>You don't know whether a record exists with a specific Record ID#, and you want to edit the record if it does exist, or add a new record.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1125
+
1126
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1127
+
1128
+ # Attempt to change Name to Fred in record 7
1129
+ # If there is no record 7, add a new record and set the Name to Fred.
1130
+ qbc.addFieldValuePair(&quot;Name&quot;,nil,nil,&quot;Fred&quot;)
1131
+ qbc.addOrEditRecord(&quot;dbiddbid&quot;,qbc.fvlist,&quot;7&quot;)
1132
+
1133
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="addOrEditRecord.rb">addOrEditRecord.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=69">Retrieve one record from a table</a><h3>Keywords</h3>get one record<br><h3>Problem:</h3>You just want to read a single existing record from a table, without having to know all the field names in the table.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1134
+ qbc = QuickBase::Client.new
1135
+ qbc.getRecord(&quot;24105&quot;,&quot;8emtadvk&quot;){|myRecord|
1136
+ myRecord.each{|key,value| puts &quot;Field: #{key}, Value: #{value}\n&quot; }
1137
+ }
1138
+ </pre><br><h3>Discussion:</h3>The record will be returned as a Ruby Hash.
1139
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getRecord.rb">getRecord.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=67">Get a list of the tables in an application</a><h3>Keywords</h3>list table name<br><h3>Problem:</h3>You need to get the list of tables in a QuickBase application.<br><h3>Solution:</h3><pre>
1140
+ require 'QuickBaseClient'
1141
+
1142
+ qbc = QuickBase::Client.new
1143
+ tableNames = qbc.getTableNames(&quot;bbtt9cjr6&quot;)
1144
+ puts &quot;\nTables in the QuickBase Application Library:\n\n&quot;
1145
+ puts tableNames.join( &quot;\n&quot;)
1146
+
1147
+ =begin
1148
+ Output of the above script:
1149
+
1150
+ Tables in the QuickBase Application Library:
1151
+
1152
+ Applications
1153
+ Versions
1154
+ Files
1155
+ Reviews
1156
+ Activity Log
1157
+ Bookmarks
1158
+ Feedback
1159
+ Featured Apps
1160
+ Categories
1161
+
1162
+ =end
1163
+
1164
+ </pre><br><h3>Discussion:</h3>This would be especially useful if the list of tables in a particular application is likely to change.
1165
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getTableNames.rb">getTableNames.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=66">Format a duration value retrieved from QuickBase</a><h3>Keywords</h3>duration format<br><h3>Problem:</h3>The QuickBaseAPI returns duration field values in milliseconds, but you need to display the value as Days, Hours, or Minutes.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1166
+
1167
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
1168
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1169
+
1170
+ # read and format the &quot;duration&quot; field from all the records in a table
1171
+ qbc.iterateRecords(&quot;dbiddbid&quot;,[&quot;duration&quot;]){|rec|
1172
+ rawValue = rec['duration']
1173
+ days = qbc.formatDuration(rawValue.dup,&quot;days&quot;)
1174
+ hours = qbc.formatDuration(rawValue.dup,&quot;hours&quot;)
1175
+ minutes = qbc.formatDuration(rawValue.dup,&quot;minutes&quot;)
1176
+ printf(&quot;Raw value: %-15s Days: %-10s Hours: %-10s Minutes: %-10s\n&quot;, rec['duration'], days, hours, minutes)
1177
+ }
1178
+
1179
+ =begin
1180
+
1181
+ Sample output from this script:
1182
+
1183
+ Raw value: 172800000 Days: 2 Hours: 48 Minutes: 2880
1184
+ Raw value: 285120000 Days: 3 Hours: 79 Minutes: 4752
1185
+ Raw value: 2160000000 Days: 25 Hours: 600 Minutes: 36000
1186
+ Raw value: 10658304000 Days: 123 Hours: 2960 Minutes: 177638
1187
+ Raw value: 37152000 Days: 0 Hours: 10 Minutes: 619
1188
+ Raw value: 86400000 Days: 1 Hours: 24 Minutes: 1440
1189
+
1190
+ =end
1191
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="formatDuration.rb">formatDuration.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=63">Format a percent value retrieved from QuickBase</a><h3>Keywords</h3>format percent<br><h3>Problem:</h3>The QuickBase API returns percent field values as a fraction. <br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1192
+
1193
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
1194
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1195
+
1196
+ # read and format the &quot;percent&quot; field from all the records in a table
1197
+ qbc.iterateRecords(&quot;dbiddbid&quot;,[&quot;percent&quot;]){|rec|
1198
+ formattedValue = qbc.formatPercent(rec['percent'])
1199
+ puts &quot;Raw percent value from QuickBase: #{rec['percent']}, Formatted value: #{formattedValue}&quot;
1200
+ }
1201
+
1202
+ =begin
1203
+
1204
+ Sample output from this script:
1205
+
1206
+ Raw percent value from QuickBase: 0.005, Formatted value: 0.5
1207
+ Raw percent value from QuickBase: 0.12, Formatted value: 12
1208
+ Raw percent value from QuickBase: 0.9999, Formatted value: 99.99
1209
+ Raw percent value from QuickBase: 0.5, Formatted value: 50
1210
+ Raw percent value from QuickBase: 0.13, Formatted value: 13
1211
+ Raw percent value from QuickBase: 0.33123, Formatted value: 33.12
1212
+
1213
+ =end
1214
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="formatPercent.rb">formatPercent.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=64">Format a currency field value retrieved from QuickBase</a><h3>Keywords</h3>currency format<br><h3>Problem:</h3>The QuickBase API returns currency values without a currency symbol, e.g. '$'.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1215
+
1216
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
1217
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1218
+
1219
+ # read and format the &quot;currency&quot; field from all the records in a table
1220
+ qbc.iterateRecords(&quot;dbiddbid&quot;,[&quot;currency&quot;]){|rec|
1221
+ formattedValue = qbc.formatCurrency(rec['currency'],{&quot;currencySymbol&quot; =&gt; &quot;$&quot;})
1222
+ puts &quot;Raw currency value from QuickBase: #{rec['currency']}, Formatted value: #{formattedValue}&quot;
1223
+ }
1224
+
1225
+ =begin
1226
+
1227
+ Sample output from this script:
1228
+
1229
+ Raw currency value from QuickBase: 7.33, Formatted value: $7.33
1230
+ Raw currency value from QuickBase: 0.33, Formatted value: $0.33
1231
+ Raw currency value from QuickBase: 1.01, Formatted value: $1.01
1232
+ Raw currency value from QuickBase: 1888888.00, Formatted value: $1888888.00
1233
+ Raw currency value from QuickBase: 1111.1111, Formatted value: $1111.1111
1234
+ Raw currency value from QuickBase: 23.23, Formatted value: $23.23
1235
+
1236
+ =end
1237
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="formatCurrency.rb">formatCurrency.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=65">Update username and password in one place</a><h3>Keywords</h3>username password update<br><h3>Problem:</h3>You have multiple API scripts that use the same username and password to access QuickBase, and don't want update all the scripts when the username and/or password changes.<br><h3>Solution:</h3><pre>On your computer, set environment variables for 'quickbase_username' and 'quickbase_password', and use them in your scripts instead of hard-coding them in the scripts.
1238
+ In Ruby and Perl, you can easily get the value of an environment variable using the global built-in 'ENV' variable.
1239
+ e.g., using the Ruby API -
1240
+
1241
+ require 'QuickBaseClient'
1242
+ qbc = QuickBase::Client.new(ENV['quickbase_username'],ENV['quickbase_password'])
1243
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=62">Make an intranet site ASAP that connects to QuickBase</a><h3>Keywords</h3>intranet site<br><h3>Problem:</h3>You need to create a simple intranet web site very quickly and it must be connected to QuickBase.<br><h3>Solution:</h3><pre>require 'rubygems'
1244
+ require 'ramaze'
1245
+ require 'QuickBaseClient'
1246
+ require 'cgi'
1247
+
1248
+ #-----------------------------------------------------------
1249
+ class MainController &lt; Ramaze::Controller
1250
+
1251
+ map '/'
1252
+ layout :page
1253
+
1254
+ #-----------------------------------------------------------
1255
+ def index
1256
+ @title = &quot;Intranet&quot;
1257
+ html = &quot;&lt;form method=\&quot;post\&quot; action=\&quot;/listQuickBaseApplications\&quot;&gt;&quot;
1258
+ html &lt;&lt; &quot;&lt;p&gt;User name:&lt;input type=\&quot;text\&quot; name=\&quot;username\&quot;&gt;&lt;/input&gt;&lt;/p&gt;&quot;
1259
+ html &lt;&lt; &quot;&lt;p&gt;Password :&lt;input type=\&quot;text\&quot; name=\&quot;password\&quot;&gt;&lt;/input&gt;&lt;/p&gt;&quot;
1260
+ html &lt;&lt; &quot;&lt;input type=\&quot;submit\&quot; name=\&quot;my_quickbase\&quot; value=\&quot;My QuickBase.\&quot;&gt;&quot;
1261
+ html &lt;&lt; &quot;&lt;/form&gt;&quot;
1262
+ end
1263
+
1264
+ #-----------------------------------------------------------
1265
+ def listQuickBaseApplications
1266
+ @title = &quot;My QuickBase&quot;
1267
+ if request['username'] and request['password']
1268
+ @qbc = QuickBase::Client.new(request['username'], request['password'])
1269
+ if @qbc and @qbc.requestSucceeded
1270
+ html = &quot;&quot;
1271
+ grantedDBname = &quot;&quot;
1272
+ grantedDBid = &quot;&quot;
1273
+ dbproc = proc { |element|
1274
+ if element.is_a?(REXML::Element)
1275
+ if element.has_text?
1276
+ if element.name == &quot;dbname&quot;
1277
+ grantedDBname = element.text
1278
+ elsif element.name == &quot;dbid&quot;
1279
+ grantedDBid = element.text
1280
+ end
1281
+ end
1282
+ end
1283
+ }
1284
+ @qbc.grantedDBs(&quot;1&quot;,&quot;1&quot;,&quot;1&quot;){|grantedDB|
1285
+ @qbc.processChildElements(grantedDB,true,dbproc)
1286
+ html &lt;&lt; &quot;&lt;br&gt;(&lt;a href=\&quot;/showSchema/#{CGI.escape(request['username'])}/#{CGI.escape(request['password'])}/#{grantedDBid}/#{CGI.escape(grantedDBname)}\&quot;&gt;schema&lt;/a&gt;) &lt;a href=\&quot;https://www.quickbase.com/db/#{grantedDBid}\&quot;&gt;#{grantedDBname}&lt;/a&gt;&quot;
1287
+ }
1288
+ html
1289
+ else
1290
+ &quot;&lt;p&gt;&lt;b&gt;Oops - something went wrong while connecting to QuickBase.&lt;br&gt;Please check your username and password.&lt;/b&gt;&lt;/p&gt;&quot;
1291
+ end
1292
+ else
1293
+ &quot;&lt;p&gt;&lt;b&gt;Oops - please specifiy your QuickBase username and password.&lt;/b&gt;&lt;/p&gt;&quot;
1294
+ end
1295
+ end
1296
+
1297
+ #-----------------------------------------------------------
1298
+ def showSchema(username,password,dbid,dbname)
1299
+ @title = &quot;#Schema for {dbname}&quot;
1300
+ html = &quot;Oops - couldn't find the schema for that table.&quot;
1301
+ @qbc = QuickBase::Client.new(username,password)
1302
+ if @qbc and @qbc.requestSucceeded
1303
+ @qbc.getSchema(dbid)
1304
+ if @qbc.requestSucceeded
1305
+ schema = &quot;&quot;
1306
+
1307
+ # if you get 'undefined variable transitive' from the next line
1308
+ # edit rexml\document.rb and change 'trans=false' to ''transitive=false'
1309
+ @qbc.qdbapi.write(schema, 3)
1310
+
1311
+ schema.gsub!(&quot;&lt;&quot;,&quot;&amp;lt;&quot;)
1312
+ schema.gsub!(&quot;&gt;&quot;,&quot;&amp;gt;&quot;)
1313
+ html = &quot;&lt;pre&gt;#{schema}&lt;/pre&gt;&quot;
1314
+ end
1315
+ end
1316
+ html
1317
+ end
1318
+
1319
+ #-----------------------------------------------------------
1320
+ def error
1321
+ &quot;&lt;p&gt;&lt;b&gt;Sorry - that is not a valid web page on this web site.&lt;/b&gt;&lt;/p&gt;&quot;
1322
+ end
1323
+
1324
+ #-----------------------------------------------------------
1325
+ def page
1326
+ %{
1327
+ &lt;html&gt;
1328
+ &lt;head&gt;
1329
+ &lt;title&gt;#@title&lt;/title&gt;
1330
+ &lt;/head&gt;
1331
+ &lt;body&gt;
1332
+ &lt;h2&gt;#@title&lt;/h2&gt;&lt;a href =&quot;/index&quot;&gt;Home&lt;/a&gt;
1333
+ &lt;hr&gt;
1334
+ #@content
1335
+ &lt;/body&gt;
1336
+ &lt;/html&gt;
1337
+ }
1338
+ end
1339
+ end
1340
+
1341
+ Ramaze.start
1342
+ </pre><br><h3>Discussion:</h3>Most people have heard of Ruby on Rails. There is now a next generation of Ruby web application frameworks that are even simpler than Rails and that are solid and flexible enough for at least intranet purposes.
1343
+
1344
+ The example above makes a web site that lists the applications and tables you can access and displays the XML schema for selected tables.
1345
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="intranet.rb">intranet.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, Ramaze ruby web framework<br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=61">Get the list of field names for a table</a><h3>Keywords</h3>field names<br><h3>Problem:</h3>You want a list of all the fields in a table<br><h3>Solution:</h3><pre>
1346
+ require 'QuickBaseClient'
1347
+
1348
+ puts &quot;Fields from the QuickBase Community Forum: &quot;
1349
+ qbc = QuickBase::Client.new
1350
+ puts qbc.getFieldNames(&quot;8emtadvk&quot;)
1351
+
1352
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getFieldNames.rb">getFieldNames.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=59">Get the value of an application variable</a><h3>Keywords</h3>application variable get<br><h3>Problem:</h3>You want to get that value of a global variable for your QuickBase application.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1353
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;,&quot;My Application Name&quot;)
1354
+ puts qbc.getApplicationVariable(&quot;var&quot;)
1355
+ </pre><br><h3>Discussion:</h3>To get a list of all the application variables, use this instead:-
1356
+
1357
+ p qbc.getApplicationVariables
1358
+
1359
+ This gets a Ruby Hash of your application variables and prints it on the screen.
1360
+
1361
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getApplicationVariable.rb">getApplicationVariable.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=58">Use the QuickBase API with JRuby </a><h3>Keywords</h3>jruby ruby api<br><h3>Problem:</h3>JRuby is a very interesting new technology that allows Java and Ruby to be combined. It would be nice to access to QuickBase API using JRuby.<br><h3>Solution:</h3><pre>1)
1362
+ Download and install the latest JRuby from http://dist.codehaus.org/jruby/.
1363
+ As of 1/14/08, jruby-bin-1.1RC1.zip is the latest for Windows.
1364
+ 2)
1365
+ Download the latest jruby-openssl gem from https://rubyforge.org/frs/?group_id=2014&amp;release_id=17809 .
1366
+ As of 1/14/08, jruby-openssl-0.1.1.gem is the latest version.
1367
+ Install this by running 'jruby gem install jruby-openssl-0.1.1.gem' using the jruby you installed in the previous step.
1368
+
1369
+ 3) Use the Ruby wrapper for QuickBase HTTP API with JRuby instead of the 'regular' version of Ruby.
1370
+
1371
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>Ingredients:</h3>JRuby, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=57">Connect QuickBase to Ruby on Rails</a><h3>Keywords</h3>rails <br><h3>Problem:</h3>You want to develop a web site using Ruby on Rails and store the data for it in QuickBase.<br><h3>Solution:</h3><pre>Use the QuickBase adapter for Rails! It is now included in the Ruby wrapper for the QuickBase API.
1372
+
1373
+ For your convenience, a copy of the Help file for the adapter is attached to this record.
1374
+ (Be sure to read the Help file from the latest version of the Ruby wrapper when you are ready to try out the adapter.)
1375
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="quickbase_adapter.rb.htm">quickbase_adapter.rb.htm</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=52">Get summary records </a><h3>Keywords</h3>summary<br><h3>Problem:</h3>The QuickBase API_DoQuery call does not let you get the records from a summary report.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1376
+
1377
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1378
+
1379
+ puts &quot;\nSummary of types of published applications in the QuickBase Application Library:\n&quot;
1380
+ printf( &quot;\n%-20s %10s %10s&quot;,&quot;Type&quot;,&quot;Count&quot;,&quot;Popularity\n&quot;)
1381
+ qbc.iterateSummaryRecords(&quot;bbtt9cjr7&quot;, [&quot;Type&quot;,&quot;Popularity&quot;]){|record|
1382
+ if record[&quot;Type&quot;]
1383
+ printf( &quot;\n%-20s %10s %10s&quot;,record[&quot;Type&quot;],record[&quot;Count&quot;],record[&quot;Popularity:Total&quot;])
1384
+ end
1385
+ }
1386
+ puts &quot;\n\nCompare the output to Summary at the bottom of this report - \n\nhttps://www.quickbase.com/db/bbtt9cjr7?a=q&amp;qid=28\n\n&quot;
1387
+ </pre><br><h3>Discussion:</h3>This example reads all the records from the Application Library and summarizes them by type. The output is similar to what you see at the bottom of this report - https://www.quickbase.com/db/bbtt9cjr7?a=q&amp;qid=28 .
1388
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="iterateSummaryRecords.rb">iterateSummaryRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=54">Select records using an SQL query</a><h3>Keywords</h3>sql query<br><h3>Problem:</h3>You want to use an SQL statement to get records, instead of using the QuickBase query language.<br><h3>Solution:</h3><pre>
1389
+ require 'QuickBaseClient'
1390
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;,&quot;QuickBase Community Forum&quot;)
1391
+ recs = qbc.doSQLQuery(&quot;SELECT Subject,Message FROM Messages WHERE Subject = 'Ruby wrapper for QuickBase HTTP API'&quot;,:Array)
1392
+ recs.each{ |rec|
1393
+ subject = rec['Subject']
1394
+ message = rec['Message']
1395
+ message.gsub!(&quot;
1396
+ &quot;,&quot;\n&quot;)
1397
+ puts &quot;Subject: --------------- #{subject} ---------------\nMessage: #{message}\n\n&quot;
1398
+ }
1399
+
1400
+ </pre><br><h3>Discussion:</h3>The doSQLQuery method was added to the Ruby API primarily for integration with Ruby on Rails. However, you can call the method directly using very simple SELECT statements. This example lists all the records in the QuickBase Community forum with the subject 'Ruby wrapper for QuickBase HTTP API'.
1401
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="sqlQuery.rb">sqlQuery.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=53">Upload all the files in a folder into new QuickBase records</a><h3>Keywords</h3>upload folder directory<br><h3>Problem:</h3>You want to upload all the files in a folder into a QuickBase table.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1402
+
1403
+ def uploadFiles1(username,password,cwd)
1404
+ qbc = QuickBase::Client.new(username,password)
1405
+ dbid = qbc.findDBByName(cwd)
1406
+ if dbid.nil?
1407
+ puts &quot;Creating a QuickBase application called '#{cwd}'.&quot;
1408
+ dbid = qbc.createDatabase(cwd,&quot;Files uploaded from #{username}\'s #{cwd} folder.&quot;)
1409
+ qbc.addField(dbid, &quot;Description&quot;,&quot;text&quot;)
1410
+ qbc.addField(dbid, &quot;File Attachment&quot;,&quot;file&quot;)
1411
+ else
1412
+ puts &quot;\nUsing the existing QuickBase application called '#{cwd}'.\n&quot;
1413
+ qbc.getSchema(dbid)
1414
+ dbid = qbc.lookupChdbid(cwd.dup)
1415
+ end
1416
+ uploadFiles3(qbc,dbid,&quot;File Attachment&quot;,cwd)
1417
+ puts &quot;\nYou can repeat this upload using uploadFilesFromFolder.exe #{username} #{password} #{dbid} file_attachment&quot;
1418
+ end
1419
+
1420
+ def uploadFiles2(username,password,dbid,fieldName,cwd)
1421
+ qbc = QuickBase::Client.new(username,password)
1422
+ uploadFiles3(qbc,dbid,fieldName,cwd)
1423
+ puts &quot;\nYou can repeat this upload using uploadFilesFromFolder.exe #{username} #{password} #{dbid} #{fieldName.gsub( /\W/, '_' )}.&quot;
1424
+ end
1425
+
1426
+ def uploadFiles3(qbc,dbid,fieldName,cwd)
1427
+ Dir.foreach(cwd){|file|
1428
+ next if file == &quot;.&quot; or file == &quot;..&quot;
1429
+ renamedFile = file.dup
1430
+ renamedFile.gsub!(&quot;&amp;&quot;,&quot;And&quot;)
1431
+ renamedFile.gsub!(&quot;'&quot;,&quot; &quot;)
1432
+ if renamedFile != file
1433
+ File.rename(file,renamedFile)
1434
+ end
1435
+ puts &quot;Uploading #{renamedFile}&quot;
1436
+ qbc.uploadFile(dbid,renamedFile,fieldName)
1437
+ }
1438
+ puts &quot;\nFinished uploading files.&quot;
1439
+ end
1440
+
1441
+ def getInputAndRun
1442
+ mycwd = Dir.pwd.gsub('/','\\')
1443
+
1444
+ if ARGV[3]
1445
+ uploadFiles2(ARGV[0],ARGV[1],ARGV[2],ARGV[3],mycwd)
1446
+ else
1447
+
1448
+ print &quot;\nPlease enter your QuickBase username: &quot;
1449
+ username = gets.chomp
1450
+ print &quot;\nPlease enter your QuickBase password: &quot;
1451
+ password = gets.chomp
1452
+ print &quot;\nEnter 'y' if to use or create a '#{mycwd}' QuickBase application for the files: &quot;
1453
+ y = gets.chomp
1454
+
1455
+ if y == &quot;y&quot; or y == &quot;Y&quot;
1456
+ uploadFiles1(username,password,mycwd)
1457
+ else
1458
+ print &quot;\nPlease enter the id of your target QuickBase table: &quot;
1459
+ dbid = gets.chomp
1460
+ print &quot;\nPlease enter the name of the QuickBase File Attachment field in your table. (e.g. File): &quot;
1461
+ fieldName = gets.chomp
1462
+ uploadFiles2(username,password,dbid,fieldName,mycwd)
1463
+ end
1464
+ end
1465
+
1466
+ end
1467
+
1468
+ getInputAndRun
1469
+ </pre><br><h3>Discussion:</h3>This script creates a QuickBase application with the same name as the folder you are in, and uploads all the files from the folder into the application. Alternatively, you can upload the files into a different table if you know the DBID of the table and the name of the target File Attachment field in the table.
1470
+
1471
+ <br><h3>See Also:</h3>https://www.quickbase.com/db/bcdcajmrg?a=dr&amp;r=b2&amp;rl=s92
1472
+ https://www.quickbase.com/db/bcdcajmrg?a=dr&amp;r=bz&amp;rl=un4<br><h3>File Attachment:</h3><a href="uploadFilesFromFolder.rb">uploadFilesFromFolder.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=55">Download file attachments from a table to a local hard drive</a><h3>Keywords</h3>download file<br><h3>Problem:</h3><br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1473
+
1474
+ def downloadFiles1(username,password,cwd)
1475
+ qbc = QuickBase::Client.new(username,password)
1476
+ dbid = qbc.findDBByName(cwd)
1477
+ qbc.getSchema(dbid)
1478
+ dbid = qbc.lookupChdbid(cwd.dup)
1479
+ downloadFiles3(qbc,username,password,dbid,&quot;File Attachment&quot;)
1480
+ end
1481
+
1482
+ def downloadFiles2(username,password,dbid,fieldName)
1483
+ qbc = QuickBase::Client.new(username,password)
1484
+ qbc.getSchema(dbid)
1485
+ downloadFiles3(qbc,username,password,dbid,fieldName)
1486
+ end
1487
+
1488
+ def downloadFiles3(qbc,username,password,dbid,fieldName)
1489
+
1490
+ fieldNames = qbc.getFieldNames(dbid)
1491
+ clist = &quot;&quot;
1492
+ fid = &quot;&quot;
1493
+ fieldNames.each{|f|
1494
+ id = qbc.lookupFieldIDByName(f)
1495
+ fid = id.dup if f == fieldName
1496
+ clist &lt;&lt; id
1497
+ clist &lt;&lt; &quot;.&quot;
1498
+ }
1499
+ clist[-1,1]=&quot;&quot;
1500
+
1501
+ if fid == &quot;&quot;
1502
+ fid = fieldName.dup
1503
+ fieldName = qbc.lookupFieldNameFromID(fid)
1504
+ end
1505
+
1506
+ qbc.iterateRecords(dbid,fieldNames,nil,nil,nil,clist,&quot;3&quot;){|r|
1507
+ if r and r[fieldName] and r[fieldName].length &gt; 0
1508
+ next if r[fieldName].include?(&quot;https:&quot;) or r[fieldName].include?(&quot;http:&quot;)
1509
+ puts &quot;Downloading #{r[fieldName]}&quot;
1510
+ qbc.downLoadFile(dbid,r[&quot;Record ID#&quot;],fid)
1511
+ if qbc.fileContents
1512
+ filename = r[fieldName]
1513
+ File.open( filename, &quot;wb&quot; ){|f|
1514
+ f.write(qbc.fileContents)
1515
+ }
1516
+ end
1517
+ end
1518
+ }
1519
+ puts &quot;\nFinished downloading files in QuickBase Record ID# order.&quot;
1520
+ puts &quot;(Later copies of files overwrite previous copies).&quot;
1521
+ puts &quot;\nYou can repeat this download using downloadFilesToFolder.exe #{username} #{password} #{dbid} #{fid}.&quot;
1522
+ end
1523
+
1524
+ def getInputAndRun
1525
+ mycwd = Dir.pwd.gsub('/','\\')
1526
+
1527
+ if ARGV[3]
1528
+ downloadFiles2(ARGV[0],ARGV[1],ARGV[2],ARGV[3])
1529
+ else
1530
+
1531
+ print &quot;\nPlease enter your QuickBase username: &quot;
1532
+ username = gets.chomp
1533
+ print &quot;\nPlease enter your QuickBase password: &quot;
1534
+ password = gets.chomp
1535
+ print &quot;\nEnter 'y' if to download the files from a '#{mycwd}' QuickBase application: &quot;
1536
+ y = gets.chomp
1537
+
1538
+ if y == &quot;y&quot; or y == &quot;Y&quot;
1539
+ downloadFiles1(username,password,mycwd)
1540
+ else
1541
+ print &quot;\nPlease enter the id of your QuickBase table: &quot;
1542
+ dbid = gets.chomp
1543
+ print &quot;\nPlease enter the name or id of the QuickBase File Attachment field in your table. (e.g. File): &quot;
1544
+ fieldName = gets.chomp
1545
+ downloadFiles2(username,password,dbid,fieldName)
1546
+ end
1547
+ end
1548
+
1549
+ end
1550
+
1551
+ getInputAndRun
1552
+ </pre><br><h3>Discussion:</h3>This script looks for a QuickBase table with the same name as your current working directory and downloads all the file attachments to your current working directory. The script starts with older records first, so newer copies of files will normally overwrite older copies.
1553
+
1554
+ You can also download the files from any table and file attachment field if you know the table id and the file attachment field id.
1555
+ <br><h3>See Also:</h3>https://www.quickbase.com/db/bcdcajmrg?a=dr&amp;r=bx&amp;rl=un3<br><h3>File Attachment:</h3><a href="downloadFilesToFolder.rb">downloadFilesToFolder.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=56">Run a Ruby API script without installing Ruby</a><h3>Keywords</h3>ruby install rubyscript2exe<br><h3>Problem:</h3>You have a written a ruby script that you want others to run on their computer, without them having to install Ruby. <br><h3>Solution:</h3><pre>RubyScript2Exe is a utility that creates a Windows executable file from a Ruby script.
1556
+
1557
+ E.g. if you have a Ruby script called 'addRecs.rb' that adds records to a QuickBase table, you can create an 'addRecs.exe' that any Windows user can run without having to install Ruby.
1558
+
1559
+ This makes it easy to write QuickBase API scripts in Ruby that anybody can run.
1560
+
1561
+ RubyScript2Exe can also generate executable files for Mac and Linux.
1562
+
1563
+ RubyScript2Exe can be downloaded from here - http://rubyforge.org/projects/rubyscript2exe/
1564
+ </pre><br><h3>Discussion:</h3>The file attached to this recipe is Windows .exe file created from the uploadFilesFromFolder.rb script from the recipe here - https://www.quickbase.com/db/bcdcajmrg?a=dr&amp;r=bx&amp;rl=s92 <br><h3>See Also:</h3>https://www.quickbase.com/db/bcdcajmrg?a=dr&amp;r=bx&amp;rl=s92<br><h3>File Attachment:</h3><a href="uploadFilesFromFolder.exe">uploadFilesFromFolder.exe</a><br><h3>Ingredients:</h3>rubyscript2exe, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=51">Find the data type of a field from its name</a><h3>Keywords</h3>data field type<br><h3>Problem:</h3>You need to get the data type of a field using the field's name.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1565
+
1566
+ qbc = QuickBase::Client.new
1567
+
1568
+ qbc.getSchema(&quot;8emtadvk&quot;) #Messages table in QuickBase Community Forum
1569
+
1570
+ puts qbc.lookupFieldTypeByName(&quot;Thread&quot;)
1571
+
1572
+ # the line above prints &quot;url&quot; on the screen
1573
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="lookupFieldTypeByName.rb">lookupFieldTypeByName.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=50">Display a more readable version of QuickBase responses</a><h3>Keywords</h3>display print XML<br><h3>Problem:</h3>QuickBase responds to requests by sending you XML. You need a slightly more readable version of this data to look at, probably for debugging or development purposes.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1574
+
1575
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1576
+
1577
+ qbc.getSchema(qbc.findDBByname(&quot;Application Library&quot;))
1578
+
1579
+ qbc.printChildElements(qbc.qdbapi)
1580
+
1581
+ =begin
1582
+
1583
+ :
1584
+ qdbapi :
1585
+ action = API_getSchema
1586
+ errcode = 0
1587
+ errtext = No error
1588
+ table :
1589
+ name = Application Library
1590
+ desc = This QuickBase contains user and QuickBase created applications that can be used by any customer of QuickBase.
1591
+ original :
1592
+ table_id = bbtt9cjr6
1593
+ cre_date = 1152727983612
1594
+ mod_date = 1171485722502
1595
+ next_record_id = 1
1596
+ next_field_id = 12
1597
+ next_query_id = 5
1598
+ def_sort_fid = 6
1599
+ def_sort_order = 0
1600
+ chdbids :
1601
+ chdbid (name=_dbid_applications ) = bbtt9cjr7
1602
+ chdbid (name=_dbid_versions ) = bbtt9cjr8
1603
+ chdbid (name=_dbid_documents ) = bbtt9cjr9
1604
+ chdbid (name=_dbid_reviews ) = bbtt9cjsc
1605
+ chdbid (name=_dbid_installs_requests ) = bbvw9jb72
1606
+ chdbid (name=_dbid_feedback ) = bbt4qb5gr
1607
+ chdbid (name=_dbid_featured_apps ) = bbt9vg4u5
1608
+ chdbid (name=_dbid_categories ) = bbtt9cjsg
1609
+ lastluserid = 0
1610
+ queries :
1611
+ query (id=1 ):
1612
+ qyname = List All
1613
+ qytype = table
1614
+ qycrit = {0.CT.''}
1615
+ qycalst = 0.0
1616
+ query (id=2 ):
1617
+ qyname = List Changes
1618
+ qytype = table
1619
+ qydesc = Sorted by Date Modified
1620
+ qycrit = {0.CT.''}
1621
+ qyopts = so-D.onlynew.
1622
+ qycalst = 0.0
1623
+ fields =
1624
+
1625
+ =end
1626
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="printChildElements.rb">printChildElements.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=49">Set a deviation field for a group of records</a><h3>Keywords</h3>average deviation<br><h3>Problem:</h3>Each record in a set of records has a number and you need to show each record's deviation from the set's average in a separate deviation field in the record. <br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1627
+
1628
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1629
+
1630
+ qbc.applyDeviationToRecords(&quot;bcc9qcnxw&quot;,&quot;number&quot;,&quot;deviation&quot;)
1631
+
1632
+ numberAverage = qbc.average(&quot;bcc9qcnxw&quot;,[&quot;number&quot;])
1633
+ puts &quot;number average: #{numberAverage['number']}&quot;
1634
+
1635
+ qbc.iterateRecords(&quot;bcc9qcnxw&quot;,[&quot;number&quot;,&quot;deviation&quot;]){|record|
1636
+ puts &quot;number: #{record['number']}, deviation: #{record['deviation']}&quot;
1637
+ }
1638
+
1639
+ =begin
1640
+
1641
+ Sample output of above script:-
1642
+
1643
+ number average: 31.0
1644
+ number: 20, deviation: 11
1645
+ number: 36, deviation: 5
1646
+ number: 56, deviation: 25
1647
+ number: 12, deviation: 19
1648
+
1649
+ =end
1650
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>percent<br><h3>File Attachment:</h3><a href="deviation.rb">deviation.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=48">Set a percentage field for a group of records</a><h3>Keywords</h3>percent sum<br><h3>Problem:</h3>Each record in a set of records has a number and you need to show each record's percentage of total in a separate percentage field in the record. <br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1651
+
1652
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1653
+
1654
+ qbc.applyPercentToRecords(&quot;bcc9qcnxw&quot;,&quot;number&quot;,&quot;percent&quot;)
1655
+
1656
+ numberTotal = qbc.sum(&quot;bcc9qcnxw&quot;,[&quot;number&quot;])
1657
+ puts &quot;number total: #{numberTotal['number']}&quot;
1658
+
1659
+ qbc.iterateRecords(&quot;bcc9qcnxw&quot;,[&quot;number&quot;,&quot;percent&quot;]){|record|
1660
+ puts &quot;number: #{record['number']}, percent: #{record['percent'].to_f*100}&quot;
1661
+ }
1662
+
1663
+ percentTotal = qbc.sum(&quot;bcc9qcnxw&quot;,[&quot;percent&quot;])
1664
+ puts &quot;percent total: #{percentTotal['percent'].to_f*100}&quot;
1665
+
1666
+ =begin
1667
+
1668
+ Sample output of above script:-
1669
+
1670
+ number total: 124.0
1671
+ number: 20, percent: 16.12903225806
1672
+ number: 36, percent: 29.03225806452
1673
+ number: 56, percent: 45.16129032258
1674
+ number: 12, percent: 9.67741935484
1675
+ percent total: 100.0
1676
+
1677
+ =end
1678
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>deviation<br><h3>File Attachment:</h3><a href="percent.rb">percent.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=4">Upload data directly from Excel into QuickBase</a><h3>Keywords</h3>Excel<br><h3>Problem:</h3>You have data in Excel that changes frequently and it is time-consuming to import it into QuickBase.<br><h3>Solution:</h3><pre>#The script below adds records directly from Excel into a
1679
+ #QuickBase table. You will obviously need to modify it for
1680
+ #your own purposes.
1681
+
1682
+
1683
+ require 'QuickBaseClient'
1684
+
1685
+ #sign into a QuickBase application using your user name and password
1686
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;my_application&quot; )
1687
+
1688
+ # if your application is a multi-table application, switch
1689
+ # to the right table
1690
+ qbc.lookupChdbid( &quot;Imported Excel data&quot; )
1691
+
1692
+ # delete all the records in the &quot;Imported Excel data&quot; table then
1693
+ # import new data from an Excel file. The field names must be at the top of the file.
1694
+ # 'h' is the letter of the last column to import.
1695
+ # Note: any commas (',') in the data are converted to semi-colons (';').
1696
+ # Uncomment the following line if you want to make your QuickBase table match the contents of your Excel file.
1697
+
1698
+ #qbc._purgeRecords
1699
+
1700
+ qbc._importFromExcel( &quot;ImportedExcelData.xls&quot;, 'h' )
1701
+
1702
+ #sign out of QuickBase
1703
+ qbc.signOut
1704
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="uploadExcelData.rb">uploadExcelData.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, Excel<br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=47">Get records matching a regular expression, e.g. 'Name' starts with A through E</a><h3>Keywords</h3>match regular expression<br><h3>Problem:</h3>You need to find records with fields matching a range of values, such as 'Name' starting with 'A' through 'E'.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1705
+
1706
+ qbc = QuickBase::Client.new
1707
+
1708
+ puts &quot;----------------------------------------------------------------------&quot;
1709
+ puts &quot;Latest Community Forum records with Subject beginning with A through E&quot;
1710
+ puts &quot;----------------------------------------------------------------------&quot;
1711
+
1712
+ qbc.iterateFilteredRecords(&quot;8emtadvk&quot;,[{&quot;Subject&quot;=&gt;&quot;^[A-E].+&quot;}],nil,nil,&quot;List Changes&quot;,nil,nil,&quot;structured&quot;,&quot;num-100&quot;) {|record|
1713
+ puts record[&quot;Subject&quot;]
1714
+ }
1715
+ </pre><br><h3>Discussion:</h3>QuickBase queries will not always be able to find particular sets of records. Filtering records using regular expressions can overcome this limitation. Regular expressions can also reduce the need for complex queries and formula fields.
1716
+ <br><h3>See Also:</h3>iterateRecords, iterateJoinRecords, iterateUnionRecords<br><h3>File Attachment:</h3><a href="iterateFilteredRecords.rb">iterateFilteredRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=46">Get the average of the values in a field from the records in a query</a><h3>Keywords</h3>average<br><h3>Problem:</h3>You need to get the average value of a field from the records returned from a query<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1717
+
1718
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1719
+
1720
+ qbc.iterateRecords(&quot;bcct3jb3b&quot;,[&quot;number&quot;]){|record|
1721
+ puts &quot;number: #{record['number']}&quot;
1722
+ }
1723
+
1724
+ average = qbc.average(&quot;bcct3jb3b&quot;,[&quot;number&quot;])
1725
+ puts &quot;average: #{average['number']}&quot;
1726
+
1727
+ =begin
1728
+
1729
+ number: 62
1730
+ number: 21
1731
+ number: 76
1732
+ number: 13
1733
+ number: 34
1734
+ number: 2
1735
+ number: 66
1736
+ number: 2
1737
+ number: 3
1738
+ average: 31.0
1739
+
1740
+ =end</pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>min,max,sum,count<br><h3>File Attachment:</h3><a href="average.rb">average.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=45">Get a count of the records in a query with a value</a><h3>Keywords</h3>count<br><h3>Problem:</h3>You need to get the number of records in a query that have a value in one or more fields<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1741
+
1742
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1743
+
1744
+ qbc.iterateRecords(&quot;bcct3jb3b&quot;,[&quot;number&quot;]){|record|
1745
+ puts &quot;number: #{record['number']}&quot;
1746
+ }
1747
+
1748
+ count = qbc.count(&quot;bcct3jb3b&quot;,[&quot;number&quot;])
1749
+ puts &quot;count: #{count['number']}&quot;
1750
+
1751
+ =begin
1752
+
1753
+ number: 62
1754
+ number: 21
1755
+ number: 76
1756
+ number: 13
1757
+ number: 34
1758
+ number: 2
1759
+ number: 66
1760
+ number: 2
1761
+ number: 3
1762
+ count: 9
1763
+
1764
+ =end</pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>min,max,sum,average<br><h3>File Attachment:</h3><a href="count.rb">count.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=44">Get the sum of the values in a field from records in a query</a><h3>Keywords</h3>sum <br><h3>Problem:</h3>You need to get the sum of the values in one or more fields from the records returned by a query<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1765
+
1766
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1767
+
1768
+ qbc.iterateRecords(&quot;bcct3jb3b&quot;,[&quot;number&quot;]){|record|
1769
+ puts &quot;number: #{record['number']}&quot;
1770
+ }
1771
+
1772
+ sum = qbc.sum(&quot;bcct3jb3b&quot;,[&quot;number&quot;])
1773
+ puts &quot;sum: #{sum['number']}&quot;
1774
+
1775
+ =begin
1776
+
1777
+ number: 62
1778
+ number: 21
1779
+ number: 76
1780
+ number: 13
1781
+ number: 34
1782
+ number: 2
1783
+ number: 66
1784
+ number: 2
1785
+ number: 3
1786
+ sum: 279.0
1787
+
1788
+ =end
1789
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>min,max,count,average<br><h3>File Attachment:</h3><a href="sum.rb">sum.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=43">Get the maximum value of a field from query results</a><h3>Keywords</h3>maximum value<br><h3>Problem:</h3>You need to get the maximum value of one or more fields from the records returned from a query<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1790
+
1791
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1792
+
1793
+ qbc.iterateRecords(&quot;bcct3jb3b&quot;,[&quot;number&quot;]){|record|
1794
+ puts &quot;number: #{record['number']}&quot;
1795
+ }
1796
+
1797
+ max = qbc.max(&quot;bcct3jb3b&quot;,[&quot;number&quot;])
1798
+ puts &quot;max: #{max['number']}&quot;
1799
+
1800
+ =begin
1801
+
1802
+ number: 62
1803
+ number: 21
1804
+ number: 76
1805
+ number: 13
1806
+ number: 34
1807
+ number: 2
1808
+ number: 66
1809
+ number: 2
1810
+ number: 3
1811
+ max: 76.0
1812
+
1813
+ =end
1814
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>min, sum, count, average<br><h3>File Attachment:</h3><a href="max.rb">max.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=42">Get the minimum value of a field from query results</a><h3>Keywords</h3>minimum value<br><h3>Problem:</h3>You need to get the minimum value of one or more fields from the records returned from a query<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1815
+
1816
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1817
+
1818
+ qbc.iterateRecords(&quot;bcct3jb3b&quot;,[&quot;number&quot;]){|record|
1819
+ puts &quot;number: #{record['number']}&quot;
1820
+ }
1821
+
1822
+ min = qbc.min(&quot;bcct3jb3b&quot;,[&quot;number&quot;])
1823
+ puts &quot;min: #{min['number']}&quot;
1824
+
1825
+ =begin
1826
+
1827
+ number: 62
1828
+ number: 21
1829
+ number: 76
1830
+ number: 13
1831
+ number: 34
1832
+ number: 2
1833
+ number: 66
1834
+ number: 2
1835
+ number: 3
1836
+ min: 2.0
1837
+
1838
+ =end
1839
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>max, sum, count, average<br><h3>File Attachment:</h3><a href="min.rb">min.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=41">Loop through records merged from two or more tables</a><h3>Keywords</h3>merge union tables query<br><h3>Problem:</h3>You want to get records using the same fields from two or more tables and/or queries and loop through the merged records.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1840
+
1841
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1842
+
1843
+ # make a list of the tables to be merged
1844
+ table1 = Hash.new
1845
+ table1[&quot;dbid&quot;]=&quot;bccr737mz&quot;
1846
+ table2 = Hash.new
1847
+ table2[&quot;dbid&quot;]=&quot;bccr737m2&quot;
1848
+ tablesToMerge = Array[table1,table2]
1849
+
1850
+ # fields are expected to be the same in both tables
1851
+ fields = Array[&quot;c&quot;]
1852
+
1853
+ puts &quot;------ Merged records from 2 tables ------&quot;
1854
+ recnum = 1
1855
+ qbc.iterateUnionRecords(tablesToMerge,fields) {|uniqueRecord|
1856
+ print &quot;\n#{recnum}. &quot;
1857
+ uniqueRecord.each{|field,value|
1858
+ print &quot;#{field}: #{value}, &quot;
1859
+ }
1860
+ recnum += 1
1861
+ }
1862
+
1863
+ =begin
1864
+
1865
+ The output using unrealistically simple data is below.
1866
+
1867
+ ------ Merged records from 2 tables ------
1868
+
1869
+ 1. c: ad,
1870
+ 2. c: c,
1871
+ 3. c: c1,
1872
+ 4. c: v,
1873
+ 5. c: Get records containing a certain value,
1874
+
1875
+ =end
1876
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="iterateUnionRecords.rb">iterateUnionRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=40">Loop through records joined from two or more tables</a><h3>Keywords</h3>join loop multiple tables<br><h3>Problem:</h3>You need to read records from multiple tables, join records that share the same values is specific fields, and loop through the joined records.<br><h3>Solution:</h3><pre>
1877
+ require 'QuickBaseClient'
1878
+
1879
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1880
+
1881
+ # make a list of the tables to be joined
1882
+ tablesToJoin = Array.new
1883
+
1884
+ table1 = Hash.new
1885
+ table1[&quot;dbid&quot;]=&quot;bccr737mz&quot; #table id
1886
+ table1[&quot;fields&quot;] = Array[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;] #fields to retrieve
1887
+ table1[&quot;joinfield&quot;] = &quot;c&quot; #field to compare across all tables' records
1888
+ tablesToJoin &lt;&lt; table1
1889
+
1890
+ table2 = Hash.new
1891
+ table2[&quot;dbid&quot;]=&quot;bccr737m2&quot;
1892
+ table2[&quot;fields&quot;] = Array[&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]
1893
+ table2[&quot;joinfield&quot;] = &quot;c&quot;
1894
+ tablesToJoin &lt;&lt; table2
1895
+
1896
+ table3 = Hash.new
1897
+ table3[&quot;dbid&quot;]=&quot;bccr737m3&quot;
1898
+ table3[&quot;fields&quot;] = Array[&quot;cc&quot;,&quot;g&quot;,&quot;gf&quot;]
1899
+ table3[&quot;joinfield&quot;] = &quot;cc&quot;
1900
+ tablesToJoin &lt;&lt; table3
1901
+
1902
+ puts &quot;------ Joined records from 3 tables ------&quot;
1903
+ recnum = 1
1904
+ qbc.iterateJoinRecords(tablesToJoin) {|joinedRecord|
1905
+ print &quot;\n#{recnum}. &quot;
1906
+ joinedRecord.each{|field,value|
1907
+ print &quot;#{field}: #{value}, &quot;
1908
+ }
1909
+ recnum += 1
1910
+ }
1911
+
1912
+ =begin
1913
+
1914
+ The output using unrealistically simple data is below.
1915
+ Note that field 'c' is in two tables and is merged.
1916
+ The value of 'c' from the second table is included in the joined record.
1917
+
1918
+ ------ Joined records from 3 tables ------
1919
+
1920
+ 1. cc: c, a: a2, b: b2, c: c, d: d, e: e, g: g, gf: sda,
1921
+ 2. cc: c, a: a2, b: b2, c: c, d: sadf, e: df, g: cv, gf: sdafad,
1922
+ 3. cc: c, a: a2, b: b2, c: c, d: sadf, e: df, g: sad, gf: sad,
1923
+ 4. cc: c, a: a2, b: b2, c: c, d: d, e: e, g: sad, gf: sad,
1924
+ 5. cc: c, a: a2, b: b2, c: c, d: sadf, e: df, g: g, gf: sda,
1925
+ 6. cc: c, a: a2, b: b2, c: c, d: sadf, e: df, g: cv, gf: sdafad,
1926
+ 7. cc: c, a: a2, b: b2, c: c, d: d, e: e, g: sad, gf: sad,
1927
+ 8. cc: c, a: a2, b: b2, c: c, d: sadf, e: df, g: sad, gf: sad,
1928
+ 9. cc: c, a: a2, b: b2, c: c, d: sadf, e: df, g: g, gf: sda,
1929
+ 10. cc: c, a: a2, b: b2, c: c, d: d, e: e, g: cv, gf: sdafad,
1930
+ 11. cc: c, a: a2, b: b2, c: c, d: sadf, e: df, g: sad, gf: sad,
1931
+ 12. cc: c, a: a, b: b, c: c, d: d, e: e, g: g, gf: sda,
1932
+ 13. cc: c, a: a, b: b, c: c, d: sadf, e: df, g: cv, gf: sdafad,
1933
+ 14. cc: c, a: a, b: b, c: c, d: sadf, e: df, g: sad, gf: sad,
1934
+ 15. cc: c, a: a, b: b, c: c, d: d, e: e, g: sad, gf: sad,
1935
+ 16. cc: c, a: a, b: b, c: c, d: sadf, e: df, g: g, gf: sda,
1936
+ 17. cc: c, a: a, b: b, c: c, d: sadf, e: df, g: cv, gf: sdafad,
1937
+ 18. cc: c, a: a, b: b, c: c, d: d, e: e, g: sad, gf: sad,
1938
+ 19. cc: c, a: a, b: b, c: c, d: sadf, e: df, g: sad, gf: sad,
1939
+ 20. cc: c, a: a, b: b, c: c, d: sadf, e: df, g: g, gf: sda,
1940
+ 21. cc: c, a: a, b: b, c: c, d: d, e: e, g: cv, gf: sdafad,
1941
+ 22. cc: c, a: a, b: b, c: c, d: sadf, e: df, g: sad, gf: sad,
1942
+
1943
+ =end
1944
+ </pre><br><h3>Discussion:</h3>This is similar to the SQL JOIN statement.<br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="iterateJoinRecords.rb">iterateJoinRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=39">Get the choices available for a multiple-choice text field</a><h3>Keywords</h3>choices multiple text get<br><h3>Problem:</h3>You want to get the list of choices available for a multiple-choice text field.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1945
+
1946
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
1947
+
1948
+ # get the available choices for the 'Ingredient 1' field in the
1949
+ # 'Recipes' table of the 'QuickBase API Cookbook v2' application
1950
+ choices = qbc.getFieldChoices( &quot;bb2mad4sr&quot;, &quot;Ingredient 1&quot; )
1951
+
1952
+ if choices
1953
+ puts &quot;\n------ Ingredients choices from the QuickBase API Cookbook v2 ------\n\n&quot;
1954
+ puts choices.join(&quot;\n&quot;)
1955
+ end
1956
+ </pre><br><h3>Discussion:</h3>This also works for 'shared' multiple-choice text fields.<br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getFieldChoices.rb">getFieldChoices.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=38">Run API code when specific emails arrive in Outlook</a><h3>Keywords</h3>Outlook email API event<br><h3>Problem:</h3>You want to run API code when specific emails arrive in your Outlook inbox, e.g. emails from QuickBase.<br><h3>Solution:</h3><pre>Create a Windows batch (.bat) file that runs your API code
1957
+ ======================================
1958
+ 1) Make a batch file, e.g. c:\iterateRecords.bat, that runs the iterateRecords.rb from this Cookbook :-
1959
+
1960
+ ruby iterateRecords.rb
1961
+
1962
+ Create an Outlook rule that runs c:\iterateRecords.bat
1963
+ ===================================
1964
+ 1) In Outlook, select the 'Tools' menu, then the 'Rules and Alerts' menu.
1965
+ 2) Create a new rule from a blank rule (not from a template).
1966
+ 3) The rule should run when emails arrive into your inbox.
1967
+ 4) Make the rule run when 'testmyrule' is in the Subject of the incoming email.
1968
+ 5) When the rule runs, it should 'run an application'. The application to run should be c:\iterateRecords.bat.
1969
+ 6) You can try the rule out by sending yourself an email with 'testmyrule' in the Subject.
1970
+
1971
+ Create a QuickBase email notification
1972
+ ========================
1973
+ These steps assume your Outlook email address is associated with your QuickBase account.
1974
+
1975
+ 1) Go to the QuickBase Commuinity Forum to set up an email notification - https://www.quickbase.com/db/bbqm84dzy?a=EmailList
1976
+ 2) Click 'Create a New Email'
1977
+ 3) Select 'Email Notification'
1978
+ 4) Put 'testmyrule' in the 'Subject' box
1979
+ 5) Click 'Save'
1980
+
1981
+ When someone modifies a record in the Community Forum, you will get an email from QuickBase with 'testmyrule' in the subject that will run the iterateRecords.rb ruby API script.
1982
+
1983
+ </pre><br><h3>Discussion:</h3>An alternative to this that doesn't require Outlook or batch files is to use the QuickBaseEventNotifier.rb that comes with the Ruby API.
1984
+ <br><h3>See Also:</h3>iterateRecords.rb
1985
+ QuickBaseEventNotifier.rb
1986
+ https://www.quickbase.com/db/bb2mad4sr?a=dr&amp;r=5&amp;rl=e68
1987
+ <br><h3>Ingredients:</h3>Outlook, Batch file, Ruby wrapper for QuickBase HTTP API<br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=37">Remove all records from a table</a><h3>Keywords</h3>remove delete records<br><h3>Problem:</h3>You need to empty out the records from a table programmatically<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
1988
+
1989
+ #loop {
1990
+
1991
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;my_application&quot; )
1992
+ qbc.lookupChdbid( &quot;my_table&quot; )
1993
+ qbc._purgeRecords
1994
+ qbc.signOut
1995
+
1996
+ # qbc = nil
1997
+ # sleep(60*60)
1998
+ #}
1999
+
2000
+ # to empty a table automatically every hour, remove
2001
+ # the '#' from the beginning of the lines above
2002
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="purgeRecords.rb">purgeRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=36">Process records returned from a query as field/value pairs</a><h3>Keywords</h3>hash process record query<br><h3>Problem:</h3>You want to process the records returned from a query using an iterator rather than an array. <br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2003
+
2004
+ qbc = QuickBase::Client.new
2005
+ puts &quot; ---------- Records from the QuickBase Community Forum containing 'Ruby wrapper' ----------&quot;
2006
+
2007
+ recordNumber=1
2008
+
2009
+ qbc.iterateRecords(&quot;8emtadvk&quot;,[&quot;Subject&quot;,&quot;Created&quot;,&quot;Message&quot;],&quot;{'0'.CT.'Ruby wrapper'}&quot;) {|record|
2010
+
2011
+ print &quot;\n\n#{recordNumber}.&quot;
2012
+
2013
+ print &quot;\nSubject: &quot;, record[&quot;Subject&quot;]
2014
+
2015
+ print &quot;\nCreated: &quot;, qbc.formatDate(record[&quot;Created&quot;])
2016
+
2017
+ message = record[&quot;Message&quot;]
2018
+ message.gsub!(&quot;
2019
+ &quot;,&quot;\n&quot;) if message.include?(&quot;
2020
+ &quot;)
2021
+
2022
+ print &quot;\nMessage: &quot;, message
2023
+
2024
+ recordNumber += 1
2025
+ }
2026
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="iterateRecords.rb">iterateRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=35">Modify fields in all records matching a query</a><h3>Keywords</h3>modify fields query<br><h3>Problem:</h3>You want to set the value of one or more fields in all records matching a query<br><h3>Solution:</h3><pre>
2027
+ require 'QuickBaseClient'
2028
+ require 'Date'
2029
+
2030
+ # login and connect to the &quot;Email Outbox&quot; application
2031
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;,&quot;Email Outbox&quot;)
2032
+
2033
+ # find the &quot;Messages&quot; table in the &quot;Email Outbox&quot; application
2034
+ outboxMessagesTable = qbc.lookupChdbid(&quot;Messages&quot;)
2035
+
2036
+ today = Date.today
2037
+ today = today.strftime(&quot;%m-%d-%Y&quot;)
2038
+
2039
+ # for every record that was created today, change the &quot;from&quot; field to &quot;fred@bedrock.com&quot; and the &quot;to&quot; field to &quot;wilma@bedrock.com&quot;
2040
+ qbc.editRecords(outboxMessagesTable,{&quot;from&quot;=&gt;&quot;fred@bedrock.com&quot;,&quot;to&quot;=&gt;&quot;wilma@bedrock.com&quot;},&quot;{'1'.EX.'#{today}'}&quot;)
2041
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="editRecords.rb">editRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=34">Run code when records are added or modified</a><h3>Keywords</h3>add change event notification code<br><h3>Problem:</h3>You want to run code whenever a record is added or modified in a particular table<br><h3>Solution:</h3><pre>require 'QuickBaseEventNotifier'
2042
+
2043
+ # check the QuickBase Community Forum every minute for new or modified records
2044
+ QuickBase::EventNotifier.watchAndRunCode(&quot;username&quot;,&quot;password&quot;,&quot;8emtadvk&quot;) {|eventNotification|
2045
+ # run this code when a record is added or modified
2046
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2047
+ fiveMinutesAgo = Time.now - (60*5)
2048
+ qbc.doQuery(&quot;8emtadvk&quot;, &quot;{'2'.GT.'#{fiveMinutesAgo.to_i}'}&quot;){ |record|
2049
+ # print records added less than 5 minutes ago
2050
+ qbc.printChildElements(record)
2051
+ }
2052
+ }
2053
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="printNewRecords.rb">printNewRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=33">List all the QuickBase applications you can access</a><h3>Keywords</h3>list accessible applications<br><h3>Problem:</h3>You need a list of the QuickBase applications that you have access to<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2054
+
2055
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2056
+ qbc.grantedDBs() { |database|
2057
+ qbc.printChildElements(database)
2058
+ }
2059
+ </pre><br><h3>Discussion:</h3>'printChildElements' is useful for printing a simplified version of any XML data returned by QuickBase.<br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="listAccessibleApplications.rb">listAccessibleApplications.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=32">Stop sending API requests to QuickBase when an error occurs</a><h3>Keywords</h3>stop API requests<br><h3>Problem:</h3>You know that there is no value in sending further API requests to QuickBase when a request fails and want to stop sending requests immediately.<br><h3>Solution:</h3><pre>require 'QuickBaseClient.rb'
2060
+
2061
+ begin
2062
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2063
+ qbc.stopOnError=true
2064
+ qbc.doQuery( &quot;bad_database_id&quot; ) # make a bad request
2065
+ qbc.doQuery( &quot;bb2mad4sr&quot; ) # QuickBase API Cookbook v2
2066
+ rescue StandardError =&gt; exception
2067
+ puts &quot;\n\n ***** Something went wrong during a request to QuickBase: ****\n#{exception}&quot;
2068
+ end
2069
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="stopOnError.rb">stopOnError.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=9">Updating the latest copy of a file in a particular Quickbase record every hour</a><h3>Keywords</h3>Upload update file<br><h3>Problem:</h3>You have a file or document on your local or drive or network drive that someone has to upload into QuickBase several times a day.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2070
+
2071
+ loop {
2072
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;my_application&quot; )
2073
+ qbc.lookupChdbid( &quot;Documents&quot; ) # the table containing the files
2074
+
2075
+ # &quot;12&quot; is the number of the record (Record ID#) to be modified
2076
+ # &quot;Document&quot; is the name of the field containing a file attachment
2077
+ # &quot;Version&quot; and &quot;Date&quot; are additional field values to modify in the record
2078
+
2079
+ qbc.updateFile( qbc.dbid, &quot;12&quot;, &quot;my_file.doc&quot;, &quot;Document&quot;, { &quot;Version&quot; =&gt; &quot;6&quot;, &quot;Note&quot; =&gt; &quot;Updated 01/30/2006&quot; } )
2080
+
2081
+ qbc.signOut
2082
+ qbc = nil
2083
+
2084
+ # wait one hour
2085
+ sleep(60*60)
2086
+ }</pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="uploadFileEveryHour.rb">uploadFileEveryHour.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=31">Upload a file into a new QuickBase record</a><h3>Keywords</h3>upload file <br><h3>Problem:</h3>You want to create a new record and upload a file into a File Attachment field in the record<br><h3>Solution:</h3><pre>
2087
+ require 'QuickBaseClient'
2088
+
2089
+ qbc = QuickBase::Client.new( &quot;username&quot;, &quot;password&quot; )
2090
+
2091
+ # upload the local file &quot;cookbookfiles.zip&quot; into the 'File Attachment' field in a new record
2092
+ # in the 'Etc.' table in the QuickBase API Cookbook v2
2093
+ qbc.uploadFile( &quot;bb2mad4su&quot;, &quot;cookbookfiles.zip&quot;, &quot;File Attachment&quot; )
2094
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="uploadFileIntoNewRecord.rb">uploadFileIntoNewRecord.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=30">Edit data offline in a simple text file</a><h3>Keywords</h3>text file offline<br><h3>Problem:</h3>You want to edit data in simple text file and send the data into to a QuickBase table<br><h3>Solution:</h3><pre>require 'QuickBaseTextData'
2095
+
2096
+ # download the Ingredients table in the QuickBase API Cookbook v2 to a text file
2097
+ QuickBase::TextData.downloadData(&quot;username&quot;,&quot;password&quot;,&quot;bb2mad4ss&quot;)
2098
+
2099
+ =begin
2100
+
2101
+ The 'downloadData' line above will write a file called 'downloadedTextData.txt' in your current directory.
2102
+ The contents will be something close to the text below. You can edit the text and send it back to QuickBase
2103
+ using QuickBase::TextData.uploadData(&quot;username&quot;,&quot;password&quot;,&quot;downloadedTextData.txt&quot;)
2104
+
2105
+ dbid:bb2mad4ss
2106
+ record:1
2107
+ Name:Ruby wrapper for QuickBase HTTP API
2108
+ Description:This is a Ruby language wrapper for the QuickBase HTTP API. It includes routines for all everything in the API, plus additional routines to reduce the amount of code you have to write to get things done using the QuickBase API.
2109
+ File Attachment:
2110
+ URL:https://www.quickbase.com/db/8emtadvk?a=dr&amp;r=ztj&amp;rl=cjtm
2111
+ Contact E-mail:
2112
+ record:2
2113
+ Name:QuickBase HTTP API
2114
+ Description:
2115
+ File Attachment:
2116
+ URL:https://www.quickbase.com/up/6mztyxu8/g/rc7/en/va/QuickBaseAPI.htm
2117
+ Contact E-mail:
2118
+ record:3
2119
+ Name:One-Click Ruby Installer for Windows
2120
+ Description:This is a [one-click, self-contained Windows installer] that contains the Ruby language itself, dozens of popular extensions and packages, a syntax-highlighting editor and execution environment, and a Windows help file that contains the full text of the book, Programming Ruby: The Pragmatic Programmer's Guide.
2121
+ File Attachment:
2122
+ URL:http://rubyinstaller.rubyforge.org/wiki/wiki.pl
2123
+ Contact E-mail:
2124
+ record:4
2125
+ Name:Visual Basic SDK
2126
+ Description:
2127
+ File Attachment:
2128
+ URL:https://www.quickbase.com/db/6mztyxu8?a=dr&amp;r=c4
2129
+ Contact E-mail:
2130
+ record:5
2131
+ Name:Perl SDK
2132
+ Description:
2133
+ File Attachment:
2134
+ URL:https://www.quickbase.com/db/6mztyxu8?a=dr&amp;r=c5
2135
+ Contact E-mail:
2136
+ record:6
2137
+ Name:Javascript SDK
2138
+ Description:
2139
+ File Attachment:
2140
+ URL:https://www.quickbase.com/db/6mztyxu8?a=dr&amp;r=c8
2141
+ Contact E-mail:
2142
+ record:7
2143
+ Name:Java SDK
2144
+ Description:
2145
+ File Attachment:
2146
+ URL:https://www.quickbase.com/db/6mztyxu8?a=dr&amp;r=c6
2147
+ Contact E-mail:
2148
+ record:8
2149
+ Name:Excel
2150
+ Description:
2151
+ File Attachment:
2152
+ URL:
2153
+ Contact E-mail:
2154
+
2155
+
2156
+ =end
2157
+ </pre><br><h3>Discussion:</h3>QuickBaseTextData.rb comes with the Ruby API for QuickBase. The file format it reads and writes is simpler than XML and more readable than CSV. It is suitable for editing small-to-medium amounts of data manually and as an intermediate format that applications can use to send data to QuickBase.<br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="downloadToTextFile.rb">downloadToTextFile.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=29">Add simple records 'offline' by entering a field in a dialog box</a><h3>Keywords</h3>offline field entry dialog<br><h3>Problem:</h3>You want to add records by typing into a dialog box and pressing Enter, rather than using a browser. You want to be able to do this while disconnected from the internet, but have the data go into QuickBase next the time you connect.<br><h3>Solution:</h3><pre>Enter this command at an operating system command-line prompt:-
2158
+
2159
+ ruby runOfflineFieldEntryDialog.rb username password dbid FieldName
2160
+
2161
+ Of course 'username' and 'password' should be your actual QuickBase username and password. 'dbid' should be the id of the table you want to add records to. 'FieldName' should be the name of a text field in that table. Your table should allow records to be added by entering just the 'FieldName' field.
2162
+ </pre><br><h3>Discussion:</h3>This is very useful for adding records quickly to a table with the least possible amount of typing or clicking and the least possible amount of your screen being occupied for input fields. It is perfect for adding items to a To-Do list table.
2163
+
2164
+ This dialog box works on any operating system that supports Ruby. The dialog box includes a button to launch QuickBase in your default browser and display your table.
2165
+ <br><h3>See Also:</h3>QuickBaseTextData.rb<br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=28">Add simple records by entering a field in a dialog box</a><h3>Keywords</h3>field entry dialog<br><h3>Problem:</h3>You want to add records by typing into a dialog box and pressing Enter, rather than using a browser.<br><h3>Solution:</h3><pre>Enter this command at an operating system command-line prompt:-
2166
+
2167
+ ruby runFieldEntryDialog.rb username password dbid FieldName
2168
+
2169
+ Of course 'username' and 'password' should be your actual QuickBase username and password. 'dbid' should be the id of the table you want to add records to. 'FieldName' should be the name of a text field in that table. Your table should allow records to be added by entering just the 'FieldName' field.
2170
+ </pre><br><h3>Discussion:</h3>This is very useful for adding records quickly to a table with the least possible amount of typing or clicking and the least possible amount of your screen being occupied for input fields. It is perfect for adding items to a To-Do list table.
2171
+
2172
+ This dialog box works on any operating system that supports Ruby. The dialog box includes a button to launch QuickBase in your default browser and display your table.
2173
+ <br><h3>See Also:</h3><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=27">Show a message when records are added or modified</a><h3>Keywords</h3>add change event notification<br><h3>Problem:</h3>You want to be notified in a message box when a record is added or modified in a table<br><h3>Solution:</h3><pre>
2174
+ require 'QuickBaseEventNotifier'
2175
+
2176
+ # show a message when a record is added or modified in the QuickBase Community Forum
2177
+ QuickBase::EventNotifier.watch(&quot;username&quot;,&quot;password&quot;,&quot;bbqm84dzy&quot;)
2178
+ </pre><br><h3>Discussion:</h3>QuickBaseEventNotifier.rb comes with the Ruby API for QuickBase. This class maintains a list of QuickBase table changes to watch for, how to be notified of the changes, how frequently to check for the changes and when to start and stop checking. It can stop checking after a specific number of checks, or stop checking after a specific number of successful checks. It can also check for records changes that only meet certain conditions. It can run also any Ruby code when an event occurs. It can be used as a simple alternative to email notifications from QuickBase.
2179
+
2180
+ The above example will check the QuickBase Community Forum every minute for new or modifed records. If a record is added or modifed, it will display a message informing you of the event and a button to launch the QuickBase Community Forum in your default browser.
2181
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="watchCommunityForum.rb">watchCommunityForum.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=25">Download a file from QuickBase</a><h3>Keywords</h3>download file<br><h3>Problem:</h3>You want to download a file from a particular File Attachment field in a particular record and table<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2182
+
2183
+ qbc = QuickBase::Client.new
2184
+
2185
+ # download the QuickBaseClient.rb.zip from record 24105 in the QuickBase Community Forum
2186
+ # '41' is the field ID of the File Attachment field
2187
+ qbc.downLoadFile(&quot;8emtadvk&quot;, &quot;24105&quot;, &quot;41&quot; )
2188
+
2189
+ # have to write the downloaded data before it exists on your local disk
2190
+ File.open( &quot;The.Latest.QuickBaseClient.rb.zip&quot;, &quot;wb&quot; ){|f|f.write(qbc.fileContents)}
2191
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="downloadFile.rb">downloadFile.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=24">Loop through records and fields returned by a query</a><h3>Keywords</h3>loop record field query<br><h3>Problem:</h3>You need to loop through the records and fields returned from a query without having to know what fields to expect<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2192
+
2193
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2194
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2195
+
2196
+ qbc.doQuery(&quot;6ewwzuuj&quot;)
2197
+
2198
+ puts &quot;\n --- QuickBase Formula Functions Reference ---\n\n&quot;
2199
+
2200
+ recordNumber = 1
2201
+ qbc.eachRecord(qbc.records){|record|
2202
+ puts &quot;\n --- Record #{recordNumber} ---&quot;
2203
+ recordNumber += 1
2204
+ qbc.eachField(record){|field|
2205
+ print qbc.lookupFieldNameFromID(field.attributes[&quot;id&quot;])
2206
+ print &quot;: &quot;
2207
+ if field.has_text?
2208
+ text = field.text.dup
2209
+ text.gsub!(&quot;
2210
+ &quot;,&quot;\n&quot;) if text.include?(&quot;
2211
+ &quot;)
2212
+ puts text
2213
+ end
2214
+ }
2215
+ }
2216
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="recordAndFieldIterator.rb">recordAndFieldIterator.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=23">Get records owned by a particular person</a><h3>Keywords</h3>record owner query find<br><h3>Problem:</h3><br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2217
+
2218
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2219
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2220
+
2221
+ communityForumRecords = qbc.getAllValuesForFields(&quot;8emtadvk&quot;,[&quot;Subject&quot;,&quot;Message&quot;],&quot;{'4'.CT.', John'}&quot;,nil,nil,&quot;6.10&quot;,nil,&quot;structured&quot;,&quot;num-10&quot;)
2222
+
2223
+ puts &quot;\n --- Ten most recent QuickBase Community Forum Records owned by ', John' ---\n\n&quot;
2224
+
2225
+ numRecords = communityForumRecords[&quot;Subject&quot;].length
2226
+ (0..(numRecords-1)).each{|index|
2227
+ print &quot;\n#{index+1})\nSubject: &quot;
2228
+ print communityForumRecords[&quot;Subject&quot;][index]
2229
+ puts &quot;\nMessage:&quot;
2230
+ puts communityForumRecords[&quot;Message&quot;][index].gsub!(&quot;
2231
+ &quot;,&quot;\n&quot;)
2232
+ }
2233
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="findJohnsLast10Records.rb">findJohnsLast10Records.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=22">Get records containing a certain value</a><h3>Keywords</h3>find query value<br><h3>Problem:</h3>You want a list of records containing a particular value in any field.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2234
+
2235
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2236
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2237
+
2238
+ communityForumRecords = qbc.getAllValuesForFields(&quot;8emtadvk&quot;,[&quot;Subject&quot;,&quot;Message&quot;],&quot;{'0'.CT.'ruby'}&quot;,nil,nil,&quot;6.10&quot;)
2239
+
2240
+ puts &quot;\n --- QuickBase Community Forum Records containing the word 'ruby' ---\n\n&quot;
2241
+
2242
+ numRecords = communityForumRecords[&quot;Subject&quot;].length
2243
+ (0..(numRecords-1)).each{|index|
2244
+ print &quot;\nSubject: &quot;
2245
+ print communityForumRecords[&quot;Subject&quot;][index]
2246
+ puts &quot;\nMessage:&quot;
2247
+ puts communityForumRecords[&quot;Message&quot;][index].gsub!(&quot;
2248
+ &quot;,&quot;\n&quot;)
2249
+ }
2250
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>getAllValuesForFields<br><h3>File Attachment:</h3><a href="findRubyRecords.rb">findRubyRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=21">Get records added today</a><h3>Keywords</h3>query added today<br><h3>Problem:</h3>You need to get a list of records added today<br><h3>Solution:</h3><pre>
2251
+ require 'QuickBaseClient'
2252
+ require 'Date'
2253
+
2254
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2255
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2256
+
2257
+ today = Date.today
2258
+ today = today.strftime(&quot;%m-%d-%Y&quot;)
2259
+ communityForumRecords = qbc.getAllValuesForFields(&quot;8emtadvk&quot;,[&quot;Subject&quot;,&quot;Message&quot;],&quot;{'1'.EX.'#{today}'}&quot;,nil,nil,&quot;6.10&quot;)
2260
+
2261
+ puts &quot;\n --- QuickBase Community Forum Records added today ---\n\n&quot;
2262
+
2263
+ numRecords = communityForumRecords[&quot;Subject&quot;].length
2264
+ (0..(numRecords-1)).each{|index|
2265
+ print &quot;\nSubject: &quot;
2266
+ print communityForumRecords[&quot;Subject&quot;][index]
2267
+ puts &quot;\nMessage:&quot;
2268
+ puts communityForumRecords[&quot;Message&quot;][index].gsub!(&quot;
2269
+ &quot;,&quot;\n&quot;)
2270
+ }
2271
+ </pre><br><h3>Discussion:</h3>These are the important parts:
2272
+
2273
+ today = Date.today
2274
+ today = today.strftime(&quot;%m-%d-%Y&quot;)
2275
+
2276
+ &quot;{'1'.EX.'#{today}'}&quot;
2277
+
2278
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getRecordsAddedToday.rb">getRecordsAddedToday.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=20">Get records in an array rather than XML</a><h3>Keywords</h3>record array loop<br><h3>Problem:</h3>You need to get records in an array that you can loop through <br><h3>Solution:</h3><pre>
2279
+ require 'QuickBaseClient'
2280
+
2281
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2282
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2283
+
2284
+ cookbookRecords = qbc.getAllValuesForFields(&quot;bb2mad4sr&quot;,[&quot;Title&quot;,&quot;Keywords&quot;])
2285
+
2286
+ puts &quot;\n --- QuickBase API Cookbook v2 ---\n\n&quot;
2287
+
2288
+ numRecords = cookbookRecords[&quot;Title&quot;].length
2289
+ (0..(numRecords-1)).each{|index|
2290
+ print &quot;Title: &quot;
2291
+ print cookbookRecords[&quot;Title&quot;][index]
2292
+ print &quot; (Keywords: &quot;
2293
+ print cookbookRecords[&quot;Keywords&quot;][index]
2294
+ puts &quot;)&quot;
2295
+ }
2296
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getAllValuesForFields.rb">getAllValuesForFields.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=19">Format a date value returned from QuickBase</a><h3>Keywords</h3>date format <br><h3>Problem:</h3>You want to format a date returned from a QuickBase API request as a regular date string instead of a number<br><h3>Solution:</h3><pre>
2297
+ require 'QuickBaseClient'
2298
+
2299
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2300
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2301
+ createdFieldValue = qbc.getAllValuesForFields(&quot;8emtadvk&quot;,[&quot;Created&quot;],&quot;{'3'.EX.'24105'}&quot;)
2302
+ createdFieldValue = createdFieldValue[&quot;Created&quot;][0]
2303
+ formattedCreatedFieldValue = qbc.formatDate(createdFieldValue)
2304
+ puts &quot;Message 24105 in the QuickBase Community Forum was created on #{formattedCreatedFieldValue} (#{createdFieldValue}).&quot;
2305
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3>getAllValuesForFields<br><h3>File Attachment:</h3><a href="formatDate.rb">formatDate.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=18">Get the dbid (database id) of a 'child' table</a><h3>Keywords</h3>id dbid multi child table<br><h3>Problem:</h3>You have to programmatically retrieve the id of a 'child' table in a multi-table application<br><h3>Solution:</h3><pre>
2306
+ require 'QuickBaseClient'
2307
+
2308
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2309
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2310
+ qbc.printRequestsAndResponses=true
2311
+ applicationDBID = qbc.findDBByname(&quot;QuickBase API Cookbook v2&quot;)
2312
+ qbc.getSchema(applicationDBID)
2313
+ childDBID = qbc.lookupChdbid(&quot;Ingredients&quot;)
2314
+ puts &quot;The dbid of the 'Ingredients' table in the QuickBase API Cookbook v2 application is #{childDBID}&quot;
2315
+
2316
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getChildTableDBID.rb">getChildTableDBID.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=17">Save request and response XML to a log file</a><h3>Keywords</h3>log debug XML<br><h3>Problem:</h3>You need to keep a log of the XML being sent to QuickBase and the XML being returned.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2317
+
2318
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2319
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2320
+ puts &quot;Logging XML requests and responses in file logfile.csv.&quot;
2321
+ qbc.logToFile( &quot;logfile.csv&quot; )
2322
+ qbc.getSchema(&quot;8emtadvk&quot;) #QuickBase Community Forum database
2323
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="logRequestAndResponseXML.rb">logRequestAndResponseXML.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=16">Show XML request/response to/from QuickBase</a><h3>Keywords</h3>debugging XML<br><h3>Problem:</h3>You are debugging a QuickBase API script and need to see the XML being sent to QuickBase and being returned from QuickBase.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2324
+
2325
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2326
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2327
+ qbc.printRequestsAndResponses = true
2328
+ puts &quot;Show the XML request and response while getting info about the QuickBase Community Forum database.&quot;
2329
+ qbc.getDBInfo(&quot;8emtadvk&quot;)
2330
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="showRequestAndResponseXML.rb">showRequestAndResponseXML.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=13">Get the last time that anything was modified in a table</a><h3>Keywords</h3>table modified<br><h3>Problem:</h3>You want to know the last time that a record or anything in the structure of a table was modified.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2331
+
2332
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2333
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2334
+ qbc.getDBInfo(&quot;8emtadvk&quot;)
2335
+ lastModifiedTimeString = qbc.formatFieldValue(qbc.lastModifiedTime,&quot;timestamp&quot;)
2336
+ puts &quot;The last thing modified in the QuickBase Community Forum was at #{lastModifiedTimeString} (#{qbc.lastModifiedTime}).&quot;
2337
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getLastModTime.rb">getLastModTime.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=14">Get the last time that a record was modified in a table</a><h3>Keywords</h3>record modified<br><h3>Problem:</h3>You want to know the last time a record was modified in a table.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2338
+
2339
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2340
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2341
+ qbc.getDBInfo(&quot;8emtadvk&quot;)
2342
+ lastRecModTimeString = qbc.formatFieldValue(qbc.lastRecModTime,&quot;timestamp&quot;)
2343
+ puts &quot;A record was last modified in the QuickBase Community Forum at #{lastRecModTimeString} (#{qbc.lastRecModTime}).&quot;
2344
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getLastRecModTime.rb">getLastRecModTime.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=15">Get the date and time a table was created</a><h3>Keywords</h3>create time<br><h3>Problem:</h3>You need to know when a table was created<br><h3>Solution:</h3><pre>
2345
+ require 'QuickBaseClient'
2346
+
2347
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2348
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2349
+ qbc.getDBInfo(&quot;8emtadvk&quot;)
2350
+ createdTimeString = qbc.formatFieldValue(qbc.createdTime,&quot;timestamp&quot;)
2351
+ puts &quot;The QuickBase Community Forum was created #{createdTimeString} (#{qbc.createdTime}).&quot;
2352
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getTimeCreated.rb">getTimeCreated.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=12">Get the number of records in a table</a><h3>Keywords</h3>number records<br><h3>Problem:</h3>You want to get the number of records in a table.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2353
+
2354
+ # change &quot;username&quot; &quot;password&quot; to your QuickBase username and password
2355
+
2356
+ qbc = QuickBase::Client.new(&quot;username&quot;,&quot;password&quot;)
2357
+
2358
+ numRecords = qbc.getNumRecords(&quot;8emtadvk&quot;)
2359
+
2360
+ puts &quot;There are #{numRecords} in the QuickBase Community Forum database&quot;
2361
+
2362
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="getNumRecords.rb">getNumRecords.rb</a><br><h3>Ingredients:</h3>One-Click Ruby Installer for Windows, Ruby wrapper for QuickBase HTTP API, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=10">Making a backup copy of an application</a><h3>Keywords</h3>backup<br><h3>Problem:</h3>You need a quick way of backing up an application.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2363
+
2364
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;my_application&quot; )
2365
+
2366
+ # &quot;true&quot; at the end means copy all the data, not just the structure of the database
2367
+ qbc.cloneDatabase( qbc.dbid, &quot;my_application_backup&quot;, &quot;backup of my_application&quot;, true )
2368
+
2369
+ qbc.signOut
2370
+ </pre><br><h3>Discussion:</h3>If you want to have only one backup copy of your application, add a call to qbc.deleteDatabase:
2371
+
2372
+ require 'QuickBaseClient'
2373
+
2374
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;my_application&quot; )
2375
+
2376
+ # save the dbid of the application
2377
+ appdbid = qbc.dbid.dup
2378
+
2379
+ qbc.findDBByname( &quot;my_application_backup&quot; )
2380
+ if qbc.dbid and qbc.errcode == &quot;0&quot;
2381
+ qbc.deleteDatabase( qbc.dbid )
2382
+ end
2383
+
2384
+ # &quot;true&quot; at the end means copy all the data, not just the structure of the database
2385
+ qbc.cloneDatabase( appdbid, &quot;my_application_backup&quot;, &quot;backup of my_application&quot;, true )
2386
+
2387
+ qbc.signOut
2388
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="backupApplication.rb">backupApplication.rb</a><br><h3>Ingredients:</h3>, , <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=2">Automatically upload CSV data into QuickBase</a><h3>Keywords</h3>Upload CSV data<br><h3>Problem:</h3>You have data in a CSV file and want to upload it into a QuickBase table frequently and quickly.<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2389
+
2390
+ #sign into your application using your user name and password
2391
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;my_application&quot; )
2392
+
2393
+ # If your application is a multi-table application, switch to the correct target table using lookupChdbid
2394
+ qbc.lookupChdbid( &quot;Imported data&quot; )
2395
+
2396
+ # delete all the records in the &quot;Imported data&quot; table then
2397
+ # import new data from a CSV file. The field names must be at the top of the file.
2398
+
2399
+ # Uncomment the following line to make your QuickBase table
2400
+ # have the same contents as your CSV file.
2401
+ #qbc._purgeRecords
2402
+
2403
+ # (change 'ImportedData.csv' to a real file name)
2404
+ qbc.importCSVFile( &quot;ImportedData.csv&quot; )
2405
+
2406
+ #sign out of QuickBase
2407
+ qbc.signOut
2408
+ </pre><br><h3>Discussion:</h3>To have this code run automatically every hour, put everything after &quot;require 'QuickBaseClient'&quot; inside this loop block:
2409
+
2410
+ loop {
2411
+
2412
+ # code to run every hour goes here...
2413
+
2414
+ # use Ruby's sleep method
2415
+ sleep(60*60)
2416
+ }
2417
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="uploadCSVData.rb">uploadCSVData.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=11">Making multiple copies of a record</a><h3>Keywords</h3>Copy records<br><h3>Problem:</h3>You want a fast way to make multiple copies of a record<br><h3>Solution:</h3><pre>require 'QuickBaseClient'
2418
+
2419
+ qbc = QuickBase::Client.new( &quot;my_username&quot;, &quot;my_password&quot;, &quot;my_application&quot; )
2420
+
2421
+ # make 6 copies of record 1
2422
+ qbc.copyRecord( &quot;1&quot;, 6 )
2423
+
2424
+ qbc.signOut
2425
+ </pre><br><h3>Discussion:</h3>This will work if my_application is a single-table application. For a multi-table application, you can use lookupChdbid( tableName ) before the copyRecord call, or if you know the ID of the table you can simply add it as the last parameter to the copyRecord call:-
2426
+
2427
+ qbc.copyRecord( &quot;1&quot;, 6, &quot;xxxxxxxxx&quot; )
2428
+ <br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="duplicateRecord.rb">duplicateRecord.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=7">Run an API script by clicking a web link</a><h3>Keywords</h3>Script URL<br><h3>Problem:</h3>You have written a script and want to run it by clicking a link in a web page.<br><h3>Solution:</h3><pre>1. Modify the qbc.makeCSVFile.qbc file installed with the ruby wrapper and make sure it does what you want by typing:
2429
+ ruby QuickBaseClient.rb run qbc.makeCSVFile.qbc
2430
+ 2. At a prompt, type ruby QuickBaseClient.rb runwebclient
2431
+ 3. Open a browser and type http://127.0.0.1:2358/qbc/qbc.makeCSVFile.qbc into the Address box.
2432
+
2433
+ &quot;127.0.0.1&quot; tells a browser to look on the user's own machine for a web server. This means that people on different computers would all have to have QuickBaseClient.rb and qbc.makeCSVFile.qbc on their computer, and qbc.makeCSVFile.qbc could do different things for each user. It is more likely that everyone will expect the same behavior when a specific URL is entered or clicked, and that most people will not have QuickBaseClient.rb or Ruby on their computer. To run command files that are on a particular machine:-
2434
+
2435
+ 1. Find out the IP address or web-accessible name of the machine.
2436
+ 2. On that machine, type ruby QuickBaseClient.rb runwebclient &lt;IP Address&gt;
2437
+ 3. In the browser Address box or web page link, use http://&lt;IP Address&gt;:2358/qbc/qbc.makeCSVFile.qbc.
2438
+
2439
+ </pre><br><h3>Discussion:</h3>This solution is for developers who don't have access to a web server. If you have access to a web server, it makes more sense to run scripts via CGI, servlets, or similar means.<br><h3>See Also:</h3><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=6">Create a daily history of the changes to a table</a><h3>Keywords</h3>Copy records<br><h3>Problem:</h3>You have records in a table and need to track changes to the records over time.<br><h3>Solution:</h3><pre>1) Copy the application using these menus in QuickBase: Go To, Miscellaneous, Copy without Data
2440
+ 2) From your copy of the application, use the menus in QuickBase to Export the table back to your original application.
2441
+ 3) At this point, you should have an empty table in your application that has exactly the same structure as your original table.
2442
+ 4) In your new table, add a text field that will contain the Record ID# of records from the original table.
2443
+ 5) You can now modify the script below to copy records from the source table to the target table:
2444
+
2445
+ require 'QuickBaseClient'
2446
+ require 'Date'
2447
+
2448
+ if ARGV.length &lt; 4
2449
+ puts &quot;\n Usage: ruby copyrecords.rb &lt;username&gt; &lt;password&gt; &lt;sourceTableDBID&gt; &lt;targetTableDBID&gt;\n&quot;
2450
+ puts &quot;\n e.g. ruby copyrecords.rb myusername mypassword xxxxxxxxx yyyyyyyyy\n.&quot;
2451
+ puts &quot;\n Adds copies of records from a main table to a history table.&quot;
2452
+ puts &quot;\n This script assumes the field names match between the two tables.\n&quot;
2453
+ exit
2454
+ end
2455
+
2456
+ qbc = QuickBase::Client.new( ARGV[0], ARGV[1] )
2457
+
2458
+ #Uncomment the following line to see the data being sent to QuickBase and returned from QuickBase
2459
+ #qbc.printRequestsAndResponses = true
2460
+
2461
+ #fieldNames is the list of fields values you want to copy
2462
+ #Change the list to match your real field names.
2463
+
2464
+ fieldNames = Array.new
2465
+ fieldNames = [ &quot;Record ID#&quot;, &quot;Date Updated&quot;, &quot;Title&quot;, &quot;Description&quot;, &quot;MutipleChoiceField&quot; ]
2466
+
2467
+ puts &quot;Adding copies of all source table records to target table&quot;
2468
+
2469
+ #fieldValues is a hash of arrays of field values from all records in the source table
2470
+ qbc.getSchema( ARGV[2] )
2471
+ fieldValues = qbc.getAllValuesForFields( ARGV[2], fieldNames )
2472
+ numRecs = fieldValues[ &quot;Record ID#&quot; ].length
2473
+
2474
+ #for each record (i) retrieved from the source table...
2475
+ (0..numRecs.to_i-1).each{ |i|
2476
+
2477
+ #clear previously uploaded field values
2478
+ qbc.clearFieldValuePairList
2479
+
2480
+ #loop through the list of field values for record i
2481
+ fieldValues.each { |fieldName,valueArray|
2482
+
2483
+ # get the value of fieldName in record i
2484
+ value = valueArray[i]
2485
+
2486
+ # copy the field name - it will need to be changed for some fields
2487
+ targetFieldName = fieldName.dup
2488
+
2489
+ # date fields must be converted from the numeric version to a format that can be sent back to QuickBase
2490
+ value = qbc.formatDate( value, nil, true ) if targetFieldName == &quot;Date Updated&quot;
2491
+
2492
+ # put the source table's Record ID# in a different field in the target table
2493
+ # (you could do this for any field that has a different name in the target table)
2494
+ targetFieldName = &quot;Source Record ID #&quot; if targetFieldName == &quot;Record ID#&quot;
2495
+
2496
+ # the values of multiple choice fields must be in the list of available choices
2497
+ if targetFieldName == &quot;MutipleChoiceField&quot;
2498
+ qbc._fieldNameAddChoices( targetFieldName, value )
2499
+ end
2500
+
2501
+ # add the field value to the list of fields to be uploaded to the target table
2502
+ qbc.addFieldValuePair( targetFieldName, nil, nil, value )
2503
+ }
2504
+
2505
+ puts &quot;Adding record #{i} of #{numRecs.to_i-1}&quot;
2506
+ qbc.addRecord( ARGV[3], qbc.fvlist )
2507
+
2508
+ # print any error message from QuickBase, if there was one
2509
+ if !qbc.requestSucceeded
2510
+ qbc.printLastError
2511
+ end
2512
+
2513
+ }
2514
+
2515
+ # signout of QuickBase
2516
+ qbc.signOut
2517
+
2518
+ </pre><br><h3>Discussion:</h3><br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="copyrecords.rb">copyrecords.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=3">Create records in table 3, using data from tables 1 &amp; 2</a><h3>Keywords</h3>Create records automatically<br><h3>Problem:</h3>You want to create records automatically in a table, using data from a different table.<br><h3>Solution:</h3><pre>
2519
+ require 'QuickBaseClient'
2520
+
2521
+ #
2522
+ # This script reads the list of records from a Documents table and a Doctors table
2523
+ # And creates mssing records in a Progress table for all the combinations of Doctors and Documents
2524
+ #
2525
+
2526
+ # Check the command line for username, password ---------------------
2527
+ if ARGV.length == 1 and ARGV[0] == &quot;?&quot;
2528
+ puts &quot;\n\nUsage: ruby makerecs.rb username password\n\nThis program adds records to the Progress table\nfor each record added to the Documents table.\n\n&quot;
2529
+ exit 1
2530
+ elsif ARGV.length &gt; 1
2531
+ username = ARGV[0]
2532
+ password = ARGV[1]
2533
+ else
2534
+ puts &quot;\nPlease enter your username and password, e.g.\n\n\truby makerecs.rb fred amliw\n\n&quot;
2535
+ exit 1
2536
+ end
2537
+
2538
+ documentsDBID = &quot;xxxxxxxxx&quot; # fictitious! please use a valid table dbid
2539
+ doctorsDBID = &quot;yyyyyyyyy&quot; # fictitious! please use a valid table dbid
2540
+ progressDBID = &quot;zzzzzzzzz&quot; # fictitious! please use a valid table dbid
2541
+
2542
+ # Signin to QuickBase ----------------------------------------------
2543
+ qbc = QuickBase::Client.new( username, password )
2544
+
2545
+ # Collect the record IDs from the Documents table -------------------
2546
+ documentRids = qbc.getAllRecordIDs( documentsDBID ) #Documents table
2547
+ puts &quot;Document IDs = #{documentRids.join( ',' )}&quot;
2548
+
2549
+ # Collect the record IDs from the Doctors table ---------------------
2550
+ doctorRids = qbc.getAllRecordIDs( doctorsDBID ) #Doctors table
2551
+ puts &quot;Doctor IDs = #{doctorRids.join( ',' )}&quot;
2552
+
2553
+ # Collect the Document and Doctor IDs from the Progress table -------
2554
+ progressIDs = qbc.getAllValuesForFields( progressDBID, [ &quot;DoctorID&quot;, &quot;DocumentID&quot; ] ) # Progress table
2555
+
2556
+ puts &quot;Progress Document IDs = #{progressIDs[&quot;DocumentID&quot;].join(',')}&quot;
2557
+ puts &quot;Progress Doctor IDs = #{progressIDs[&quot;DoctorID&quot;].join(',')}&quot;
2558
+
2559
+ # Collect the Documents that are missing from the Progress table ----------------
2560
+ missingProgressDocuments = Array.new
2561
+ documentRids.each{ |documentRid|
2562
+ if not progressIDs[&quot;DocumentID&quot;].include?( documentRid )
2563
+ missingProgressDocuments &lt;&lt; documentRid
2564
+ end
2565
+ }
2566
+
2567
+ puts &quot;Missing Progress Document IDs = #{missingProgressDocuments.join(',')}&quot;
2568
+
2569
+ # For each missing Document, add a record to the Progress table for each Doctor -
2570
+ missingProgressDocuments.each{ |documentRid|
2571
+ doctorRids.each{ |doctorRid|
2572
+ qbc.clearFieldValuePairList
2573
+ qbc.addFieldValuePair( &quot;DocumentID&quot;, nil, nil, documentRid )
2574
+ fieldValueList = qbc.addFieldValuePair( &quot;DoctorID&quot;, nil, nil, doctorRid )
2575
+ qbc.addRecord( progressDBID, fieldValueList )
2576
+ }
2577
+ }
2578
+
2579
+ # Signout from QuickBase --------------------------------------------
2580
+ qbc.signOut
2581
+
2582
+ </pre><br><h3>Discussion:</h3>This is just one example solution that may not be precisely what you are looking for. However, it should be possible to follow the basic logic in this script to address your particular situation.<br><h3>See Also:</h3><br><h3>File Attachment:</h3><a href="makerecs.rb">makerecs.rb</a><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR><h2><a href="https://www.quickbase.com/db/bcdcajmrg?a=dr&rid=8">Access QuickBase from a command line instead of a browser</a><h3>Keywords</h3>Command line<br><h3>Problem:</h3>You want to query and manipulate QuickBase data from a command line prompt and/or a batch file or script.<br><h3>Solution:</h3><pre>Install ruby and the ruby wrapper. In the folder containing QuickBaseclient.rb, type:
2583
+
2584
+ ruby QuickBaseClient.rb run
2585
+
2586
+ The commands available interactively can be entered into a text file and run 'hands-off' using:
2587
+
2588
+ ruby QuickBaseClient.rb run &lt;filename&gt;
2589
+
2590
+ </pre><br><h3>Discussion:</h3>This command line provides a convenient way to perform simple routines against QuickBase without using a browser. It is especially useful for tasks that have to be done very frequently. It also helps developers to explore the QuickBase API and debug API scripts.<br><h3>See Also:</h3><br><h3>Ingredients:</h3>Ruby wrapper for QuickBase HTTP API, One-Click Ruby Installer for Windows, <br><h3>Chef:</h3><br><HR></BODY>