Hi Guys,
Can you help with this, I want to pass/post the subtable (App A) data to subtable (App B) I just can’t figure out how to use GET/POST Rest API on this problem.
Here is my code:
(function() {
‘use strict’;
var events = [‘app.record.create.submit’, ‘app.record.edit.submit’];
kintone.events.on (events, function (event) {
var record = event.record;
var product_code = record[‘productcode’].value;
var body = {
‘app’: XXX,
‘query’:‘prod_code = "’ + product_code + ‘"’
}
kintone.api(kintone.api.url(’/k/v1/records’, true), ‘GET’, body, function (resp) {
var recordd = kintone.app.record.get();
var Table11 = recordd.record.TableTestB.value;//Copy table
if (Table11.length === 1) {
Table11.pop(); //Erase the first line
for (var i = 0; i < resp.records.length; i++) {
for (var j = 0; j < resp.records[i].TableTest.value.length; j++) {
if (resp.records[i].TableTestB.value[j].value.prod_code.value === product_code) {
var DateB = resp.records[i].TableTest.value[j].value.DateB.value;
var NumberB = resp.records[i].TableTest.value[j].value.NumberB.value;
// Add line
Table11.push({
value: {
“DateA”: {
type: “DATE”,
value: DateB
},
“QuantityA”: {
type: “NUMBER”,
value: NumberB
}
}
});
}
}
kintone.app.record.set(recordd);
}
}
return event;
});
});
})();
Thank you so much for the help.