Copy data from another app

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);
});
});

});
})();

Hello Yoshida-san,

As one of many ways to create your process, you should try to create a process in the following order:

  1. Try to create a process that can add a record to App A and App B, C from data outside the table using “app.record.create.submit.success”.

  2. If step 1 is successful, try to create a process that can add a record to App A and App B, C from data within the table using “app.record.create.submit.success”.

  3. If step 2 is successful, try to create a process that can add record either to App A or App B, C depending on the data’s value within the table using “app.record.create.submit.success”. This should require some IF statements.