In the dropdown, the data related to the specified value is displayed in the sub-table.
Problem 1: Even if the dropdown value is changed, it is not reflected in the subtable.
Problem 2: I don’t know how to initialize the subtable.
Could anyone please teach me?
(function() {
“use strict”;
kintone.events.on([‘app.record.create.show’,‘app.record.edit.show’,‘app.record.create.change.User’,‘app.record.edit.change.User’,‘app.record.create.change.Charge’, ‘app.record.edit.change.Charge’], function(e){
var record = e.record;
var orderdatas = {};
var tt = 0;
var Name = record[‘Charge’].value
var body = {
‘app’: 127,
‘query’: ‘Charge = "’ + Name + ‘"’
}
return kintone.api(kintone.api.url(‘/k/v1/records’, true), ‘GET’, body).then(function(resp) {
resp.records.forEach(function(record) {
tt = tt + 1;
var Address1 = record[“Address1”].value;
var Address2 = record[“Address2”].value;
orderdatas[tt] = {
“Address11”: Address1,
“Address12”: Address2
}
//window.alert(1);
});
return setData();
});
function setData() {
var TableB = record[‘User’].value;
var index = TableB.length - 1;
for (var i = 0; i <= index; i++) {
TableB.splice(0, 1);
}
for (var key in orderdatas) {
TableB.push({
value: {
“Address11”: {value: orderdatas[key][“Address11”], type: “SINGLE_LINE_TEXT”},
“Address12”: {value: orderdatas[key][“Address12”], type: “SINGLE_LINE_TEXT”}
}
});
}
return e;
}
});
})();