お世話になっております。
以下のコードにて、カーソルを使った複数レコードの削除を試みたのですがエラーになってしまいます。
解決方法をご教授いただけないでしょうか。
よろしくお願い致します。
return kintone.api(kintone.api.url(‘/k/v1/records/cursor’, true), ‘POST’, { ‘app’: 43, ‘fields’: [‘$id’], ‘query’: query })
.then(function (resp) {
alert(JSON.stringify(resp));…※①
// カーソル ‘GET’
return kintone.api(kintone.api.url(‘/k/v1/records/cursor’, true), ‘GET’, { ‘id’ : resp.id })
}).then(function (resp2) {
alert(JSON.stringify(resp2));…※②
// 削除するレコードのレコードID配列を作成
let ids = [];
for (let i = 0; i < resp.totalCount; i++) {
ids.push(resp2.records[i].$id.value);
};
// ‘DELETE’ 実行
return kintone.api(kintone.api.url(‘/k/v1/records’, true), ‘DELETE’, { ‘app’: 43, ‘ids’: ids });
}).then(function (resp3) {
alert(‘正常終了’);
return event;
}).catch(function (error) {
alert(‘異常終了’);
return event;
});
現象としては、※①部分でrespの内容をalert表示させるとidにカーソルidが入っており、totalCountも想定の件数が表示されますが、直後に’異常終了’がalertされます。
※2部分のalert(resp2)は実行されません。