エントリーを追加するときにデータを統合する

This commit is contained in:
Mouriya
2024-06-17 15:22:10 +09:00
parent 5fdb23d6d5
commit d2f271e3cd

View File

@@ -84,41 +84,32 @@ export class DataMappingAction implements IAction {
this.actionProps = prop.actionProps; this.actionProps = prop.actionProps;
this.dataMappingProps = prop.ActionValue as Props; this.dataMappingProps = prop.ActionValue as Props;
console.log(prop.ActionValue); console.log(prop.ActionValue);
// this.initTypedActionProps(); // this.initTypedActionProps();
let result = { let result = {
canNext: true, canNext: true,
result: "", result: "",
} as IActionResult; } as IActionResult;
try { try {
for (const item of this.dataMappingProps.dataMapping) { const record = this.dataMappingProps.dataMapping
if (item.from.objectType === "variable") { .filter(
if ( (item) =>
item.from.objectType === "variable" &&
item.from.name.name && item.from.name.name &&
item.to.app && item.to.app &&
item.to.fields && item.to.fields &&
item.to.fields.length > 0 item.to.fields.length > 0
) { )
const value = getValueByPath( .reduce((accumulator, item) => {
context.variables, return {...accumulator, [item.to.fields[0].code]: {
item.from.name.name value: getValueByPath(context.variables, item.from.name.name),
); }};
if (value) { }, {});
await kintone.api( if (record && Object.keys(record).length > 0) {
kintone.api.url("/k/v1/record.json", true), await kintone.api(kintone.api.url("/k/v1/record.json", true), "POST", {
"POST", app: this.dataMappingProps.sources.app.id,
{ record: record,
app: item.to.app.id, });
record: {
[item.to.fields[0].code]: {
value: value,
},
},
}
);
}
}
}
} }
} catch (error) { } catch (error) {
console.error("DataMappingAction error", error); console.error("DataMappingAction error", error);