Kintone Update all Records in Index

Hey, I was wondering if there was any way to update all records in the index page. Or if that is not possible, any other way to bulk update the records inside the app. Any help or comments is appreciated.

 

Sample code:

kintone.events.on(“app.record.index.show”, function(event) {
var records = event.records;
for (var i = 0; i < records.length; i++) {
var record = records[i];
record[‘test’].value = “Some Value”;
}

return event;

});

|

Hi James,

 

After an event (app.record.index.show) triggered to display the record list page, the value cannot be updated in the notification processing so that with your sample quote, the value cannot be updated.

▼ Events when the record detail screen is displayed

*Please see ”What you can do with the event object” 

https://developer.kintone.io/hc/en-us/articles/212494758-Record-List-Event

Therefore, if you would like to update a record in app.record.index.show, you must use the batch record update “PUT” method.

Please note that record bulk update “PUT” can update up to 100 records in a single run.

Therefore, if you want to update more than 100 records in bulk, you might want to write a coding like recursion processing. If it is difficult for you to write such, I would suggest using the following plug-in.

▼ JOYZO Bulk Update

https://www.kintone.com/add-ons/joyzo-bulk-update/

|

As a follow up, you can also bulk update the contents of a form’s records by exporting them to a delimited text file (such as CSV or Excel), modifying the data inside the file, then exporting back to Kintone.

https://get.kintone.help/k/en/user/using_app/import_records.html

I ended up getting it work thanks to Junko’s tip on using the “PUT” method. We tried exporting the files to a CSV and modifying each time but that would be to time consuming for how many records we have to update. This code updates each value every time the index page is shown and more complicated equations can be used in this simple example.

 

My Code:

kintone.events.on(‘app.record.index.show’, function (event) {

  var records = event.records;

  for(var i = 0; i < records.length; i++) {

    var record = records[i];

    var tempID = record.<record number/ID>.value;  //To get ID in a field, just use a record number field and it is autofilled

    var body = {

         app: kintone.app.getID(),

         id: tempID,

        record:  {  “fieldname”:  { “value”: <Enter updated value here>  },

                        “fieldname2”: { “value”: <Enter 2nd value to be updated> }

        };

       kintone.api(’/k/v1/record’, ‘PUT’, body);

     }

 });