Hi Dev team,
Previously, I did it when passing all the values to 1 App A, but for now, due to the need to choose from the input values, we will divide it into 2 separate App with the same input. (assuming it is based on [Type] as shown above). The way I did it, created 1 more id for App B, but still can’t run, so please support me. Thank you so much. Currently, the code is only for App A. Want to split up more App B
(function () {
"use strict";
kintone.events.on("app.record.create.submit.success", function (event) {
var postApp = 70;
var recId = event.recordId;
var subTable = 'maintable';
var headers = [
'name_company',
'phone',
];
var record = event.record;
var table = event.record.maintable.value;
var array = [];
return kintone.api(kintone.api.url('/k/v1/records', true), 'POST', {
app: postApp,
records: event.record[subTable].value.map(function (row) {
headers.forEach(function (header) {
row.value[header] = event.record[header];
});
return row.value;
})
}).then(function (resp) {
console.log(resp);
for (var i = 0; i < table.length; i++) {
array.push({
"id": table[i].id,
"value": {
"id": {
"value": resp.ids[i]
}
}
});
}
var body = {
"app": kintone.app.getId(),
"id": recId,
"record": {
"maintable": {
"value": array
}
}
}
return kintone.api(kintone.api.url('/k/v1/record', true), 'PUT', body).then(function (resp) {
// success
console.log(resp);
}, function (error) {
// error
console.log(error);
});
});
});
})();