エントリーを追加するときにデータを統合する
This commit is contained in:
@@ -91,34 +91,25 @@ export class DataMappingAction implements IAction {
|
|||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user