Discussions

Expand all | Collapse all

Edit all records in a table with an array

  • 1.  Edit all records in a table with an array

    Posted 01-08-2019 14:01
    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.


  • 2.  RE: Edit all records in a table with an array

    Posted 01-08-2019 15:00
    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


  • 3.  RE: Edit all records in a table with an array

    Posted 01-08-2019 15:04
    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?


  • 4.  RE: Edit all records in a table with an array

    Posted 01-09-2019 00:42
    Geofrey,
    If the goal is to assign randomly have you considered a formula field based off the Record ID#


  • 5.  RE: Edit all records in a table with an array

    Posted 01-09-2019 13:53
    Hmm, I have not. Would you be able to use this to equally distribute the records?


  • 6.  RE: Edit all records in a table with an array

    Posted 01-09-2019 14:25
    Yes, because the record ID#s are random.  Well i mean that they are sequential so you can use them to allow records to "agents" in a round robin fashion.

    For example if you run a report sorted by [Record ID#] and then have a column with a formula like

    REM([Record ID#],8) +1, then you should see that column counting up from 1 to 8 and then start over at 1.

    https://login.quickbase.com/db/6ewwzuuj?a=dr&r=bu&rl=bh9h">https://login.quickbase.com/db/6ewwzuuj?a=dr&r=bu&rl=bh9h">https://login.quickbase.com/db/6ewwzuuj?a=dr&r=bu&rl=bh9h










  • 7.  RE: Edit all records in a table with an array

    Posted 01-09-2019 15:30
    That works for my problem. Thank you for your help!