mirror of
https://github.com/n8n-io/n8n.git
synced 2024-09-20 06:47:32 -07:00
fix(Pipedrive Node): Resolve properties not working
This commit is contained in:
parent
e1b3b4d05a
commit
c853b8078e
|
@ -233,16 +233,18 @@ export function pipedriveResolveCustomProperties(
|
||||||
): void {
|
): void {
|
||||||
let customPropertyData;
|
let customPropertyData;
|
||||||
|
|
||||||
|
const json = item.json as IDataObject;
|
||||||
|
|
||||||
// Itterate over all keys and replace the custom ones
|
// Itterate over all keys and replace the custom ones
|
||||||
for (const key of Object.keys(item)) {
|
for (const key of Object.keys(json)) {
|
||||||
if (customProperties[key] !== undefined) {
|
if (customProperties[key] !== undefined) {
|
||||||
// Is a custom property
|
// Is a custom property
|
||||||
customPropertyData = customProperties[key];
|
customPropertyData = customProperties[key];
|
||||||
|
|
||||||
// value is not set, so nothing to resolve
|
// value is not set, so nothing to resolve
|
||||||
if (item[key] === null) {
|
if (json[key] === null) {
|
||||||
item[customPropertyData.name] = item[key];
|
json[customPropertyData.name] = json[key];
|
||||||
delete item[key];
|
delete json[key];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,31 +267,32 @@ export function pipedriveResolveCustomProperties(
|
||||||
'timerange',
|
'timerange',
|
||||||
].includes(customPropertyData.field_type)
|
].includes(customPropertyData.field_type)
|
||||||
) {
|
) {
|
||||||
item[customPropertyData.name as string] = item[key];
|
json[customPropertyData.name as string] = json[key];
|
||||||
delete item[key];
|
delete json[key];
|
||||||
// type options
|
// type options
|
||||||
} else if (
|
} else if (
|
||||||
['enum', 'visible_to'].includes(customPropertyData.field_type) &&
|
['enum', 'visible_to'].includes(customPropertyData.field_type) &&
|
||||||
customPropertyData.options
|
customPropertyData.options
|
||||||
) {
|
) {
|
||||||
const propertyOption = customPropertyData.options.find(
|
const propertyOption = customPropertyData.options.find(
|
||||||
(option) => option.id.toString() === item[key]!.toString(),
|
(option) => option.id.toString() === json[key]!.toString(),
|
||||||
);
|
);
|
||||||
if (propertyOption !== undefined) {
|
if (propertyOption !== undefined) {
|
||||||
item[customPropertyData.name as string] = propertyOption.label;
|
json[customPropertyData.name as string] = propertyOption.label;
|
||||||
delete item[key];
|
delete json[key];
|
||||||
}
|
}
|
||||||
// type multioptions
|
// type multioptions
|
||||||
} else if (['set'].includes(customPropertyData.field_type) && customPropertyData.options) {
|
} else if (['set'].includes(customPropertyData.field_type) && customPropertyData.options) {
|
||||||
const selectedIds = (item[key] as string).split(',');
|
const selectedIds = (json[key] as string).split(',');
|
||||||
const selectedLabels = customPropertyData.options
|
const selectedLabels = customPropertyData.options
|
||||||
.filter((option) => selectedIds.includes(option.id.toString()))
|
.filter((option) => selectedIds.includes(option.id.toString()))
|
||||||
.map((option) => option.label);
|
.map((option) => option.label);
|
||||||
item[customPropertyData.name] = selectedLabels;
|
json[customPropertyData.name] = selectedLabels;
|
||||||
delete item[key];
|
delete json[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
item.json = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sortOptionParameters(
|
export function sortOptionParameters(
|
||||||
|
|
|
@ -4900,7 +4900,7 @@ export class Pipedrive implements INodeType {
|
||||||
|
|
||||||
if (customProperties !== undefined) {
|
if (customProperties !== undefined) {
|
||||||
for (const item of returnData) {
|
for (const item of returnData) {
|
||||||
await pipedriveResolveCustomProperties(customProperties, item);
|
pipedriveResolveCustomProperties(customProperties, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue