Skip to main content
Question

Edit all records in a table with an array

  • January 8, 2019
  • 0 replies
  • 72 views

How would I use an API and or code page to edit every record in a table with the contents of an array?

I want to essentially split up the records evenly and assign them to 8 different names.
This topic has been closed for replies.

  • Quickbase Alumni
  • January 8, 2019
I assume you are doing something like (1) assigning a set of workers to a list of tasks or (2) assigning as set of salespeople to a list of leads.

Assume by some means you have a array of rids and an array of workers:
var rids = [1,2,3,10,11,12,101,102,103];
var workers = ["Larry", "Curly", "Moe"];
This code will produce a blob of csv you can import which will evenly assign workers to the list of records:
var csv = _.chain(rids)
  .shuffle()
  .map(function(rid, index) {
    return '${rid}, ${workers[Math.floor(index % n)]}';
  })
  .value()
  .join('\n');
console.log(csv);
11, Larry
1, Curly
12, Moe
102, Larry
10, Curly
2, Moe
3, Larry
103, Curly
101, Moe

  • Author
  • Quickbase Alumni
  • January 8, 2019
Ah thank you. Is there any way to chop this down to a URL formula that will EditRecord and just assign each record sequentially from an array?

Geofrey,
If the goal is to assign randomly have you considered a formula field based off the Record ID#