Forum Discussion
- AustinKQrew CommanderWhat are you calling it with? You could use a code page and send the user there with all the required FIDs in the URL. Or if you know of a way to get all the records into a report you could send the user to the code page and have the page query that report and pull in all the FIDs you needed and then do whatever you want, like loop through them calling the API command each time, and then send the user back to where they came from.
I do something similar with a few things but it is more like I have a custom website that is hosted inside Quickbase that takes advantage of the code and HTML pages to allow the user to input some RIDs and update records in a popup window.- AdamKeever1Qrew CommanderI basically have >200 multiple choice fields that will be used for check lists and I want to update the field choices in bulk rather than one by one. I can update them with the RESTful API and also with Postman, but I only know how to do one field at a time.
I will do one at a time if I have to, but I thought I would do some research and try to learn how to batch update field properties in the event that it is ever needed again. I can use IOL (I know injecting javascript is being deprecated) to update properties of multiple fields in one go, but I have not been able to figure out the correct syntax for the "choices".
Here is what works for a single field using the RESTful API:
{"properties": { "choices": [ "OK", "NOK", "N/A" ] }
Here is what works for a single field using Postman:POST https://[QBREALM].com/db/[DBID] HTTP/1.0 Content-Type: application/xml Content-Length: QUICKBASE-ACTION: API_FieldAddChoices <qdbapi> <udata>mydata</udata> <usertoken>usertoken</usertoken> <fid>8</fid> <choice>OK</choice> <choice>NOK</choice> <choice>N/A</choice> </qdbapi>
Here is the body (update.js) of the image on load that will successfully change the decimal places of multiple numeric fields on load:
var dbid = "<your dbid>"; var apptoken = "<your apptoken>"; var fids = [8, 9, 10]; var promise, promises = []; $.ajaxSetup({data: {apptoken: apptoken}}); _.each(fids, function(fid) { promise = $.post(dbid, { act: "API_SetFieldProperties", fid: fid, decimal_places: "6" }); promises.push(promise); }); $.when(promises).then(function() { alert("DONE!!!"); });
I have tried using the following with syntax no success:choices: ["OK", "NOK", "N/A"]
choices: "OK", "NOK", "N/A"
properties: {choices: ["OK", "NOK", "N/A"]}
properties: {choices: "OK", "NOK", "N/A"}
I have also tried swapping the API with API_FieldAddChoices to no avail. Any thoughts?
------------------------------
Adam Keever
------------------------------- AdamKeever1Qrew CommanderUsing:
act: "API_FieldAddChoices", fid: fid, choice: "OK"
in the IOL added "OK" to all of the fields listed. So two more iterations adding in "NOK", and "N/A" accomplished updating all of the multiple choice field lists to "OK, NOK, N/A".
I still would like to figure out how to do this is one pass if anyone has any suggestions.
------------------------------
Adam Keever
------------------------------