エントリーを追加するときにデータを統合する
This commit is contained in:
@@ -84,41 +84,32 @@ export class DataMappingAction implements IAction {
|
||||
this.actionProps = prop.actionProps;
|
||||
this.dataMappingProps = prop.ActionValue as Props;
|
||||
console.log(prop.ActionValue);
|
||||
|
||||
|
||||
// this.initTypedActionProps();
|
||||
let result = {
|
||||
canNext: true,
|
||||
result: "",
|
||||
} as IActionResult;
|
||||
try {
|
||||
for (const item of this.dataMappingProps.dataMapping) {
|
||||
if (item.from.objectType === "variable") {
|
||||
if (
|
||||
const record = this.dataMappingProps.dataMapping
|
||||
.filter(
|
||||
(item) =>
|
||||
item.from.objectType === "variable" &&
|
||||
item.from.name.name &&
|
||||
item.to.app &&
|
||||
item.to.fields &&
|
||||
item.to.fields.length > 0
|
||||
) {
|
||||
const value = getValueByPath(
|
||||
context.variables,
|
||||
item.from.name.name
|
||||
);
|
||||
if (value) {
|
||||
await kintone.api(
|
||||
kintone.api.url("/k/v1/record.json", true),
|
||||
"POST",
|
||||
{
|
||||
app: item.to.app.id,
|
||||
record: {
|
||||
[item.to.fields[0].code]: {
|
||||
value: value,
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
.reduce((accumulator, item) => {
|
||||
return {...accumulator, [item.to.fields[0].code]: {
|
||||
value: getValueByPath(context.variables, item.from.name.name),
|
||||
}};
|
||||
}, {});
|
||||
if (record && Object.keys(record).length > 0) {
|
||||
await kintone.api(kintone.api.url("/k/v1/record.json", true), "POST", {
|
||||
app: this.dataMappingProps.sources.app.id,
|
||||
record: record,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("DataMappingAction error", error);
|
||||
|
||||
Reference in New Issue
Block a user