Hi,
you can use that piece
Just set you table name, and ensure that letter case is ok for “amount” fieldname.
let table = base.getTable(‘YourTable’);
let query = await table.selectRecordsAsync();
function setValue(rec){return {‘id’:rec.id,‘fields’:{‘amount’:’’}}};
let updates=query.records.map(setValue);
while (updates.length > 0) {
await table.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50); }
Hi,
you can use that piece
Just set you table name, and ensure that letter case is ok for “amount” fieldname.
let table = base.getTable(‘YourTable’);
let query = await table.selectRecordsAsync();
function setValue(rec){return {‘id’:rec.id,‘fields’:{‘amount’:’’}}};
let updates=query.records.map(setValue);
while (updates.length > 0) {
await table.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50); }
Thank you so much!! You made it !!!
//在庫数の初期化
let table = base.getTable("C_商品");
let query = await table.selectRecordsAsync();
function setValue(rec){return {id:rec.id,fields:{amount:null}}};
let updates=query.records.map(setValue);
while (updates.length > 0) {
await table.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50); }
Thank you so much!! You made it !!!
//在庫数の初期化
let table = base.getTable("C_商品");
let query = await table.selectRecordsAsync();
function setValue(rec){return {id:rec.id,fields:{amount:null}}};
let updates=query.records.map(setValue);
while (updates.length > 0) {
await table.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50); }
btw, using 50 record batch with ‘slice’ is good to show script basic for beginners.
since we have another array method ‘splice’, that delete X records and return them, we can do it in single step.
also, we can use our function not just to del, but also for copy from one field to another and whatever. like this:
let table = base.getTable('your_Table’);
let query = await table.selectRecordsAsync();
function setValue(rec){return {‘id’:rec.id,‘fields’:{‘destination’:rec.getCellValue(‘source’)}}};
let updates=query.records.map(setValue);
while (updates.length > 0) await table.updateRecordsAsync(updates.splice(0, 50));
btw, using 50 record batch with ‘slice’ is good to show script basic for beginners.
since we have another array method ‘splice’, that delete X records and return them, we can do it in single step.
also, we can use our function not just to del, but also for copy from one field to another and whatever. like this:
let table = base.getTable('your_Table’);
let query = await table.selectRecordsAsync();
function setValue(rec){return {‘id’:rec.id,‘fields’:{‘destination’:rec.getCellValue(‘source’)}}};
let updates=query.records.map(setValue);
while (updates.length > 0) await table.updateRecordsAsync(updates.splice(0, 50));
Thank you for additional explain.Deepen my understanding :face_with_monocle: