mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08: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 {
|
||||
let customPropertyData;
|
||||
|
||||
const json = item.json as IDataObject;
|
||||
|
||||
// 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) {
|
||||
// Is a custom property
|
||||
customPropertyData = customProperties[key];
|
||||
|
||||
// value is not set, so nothing to resolve
|
||||
if (item[key] === null) {
|
||||
item[customPropertyData.name] = item[key];
|
||||
delete item[key];
|
||||
if (json[key] === null) {
|
||||
json[customPropertyData.name] = json[key];
|
||||
delete json[key];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -265,31 +267,32 @@ export function pipedriveResolveCustomProperties(
|
|||
'timerange',
|
||||
].includes(customPropertyData.field_type)
|
||||
) {
|
||||
item[customPropertyData.name as string] = item[key];
|
||||
delete item[key];
|
||||
json[customPropertyData.name as string] = json[key];
|
||||
delete json[key];
|
||||
// type options
|
||||
} else if (
|
||||
['enum', 'visible_to'].includes(customPropertyData.field_type) &&
|
||||
customPropertyData.options
|
||||
) {
|
||||
const propertyOption = customPropertyData.options.find(
|
||||
(option) => option.id.toString() === item[key]!.toString(),
|
||||
(option) => option.id.toString() === json[key]!.toString(),
|
||||
);
|
||||
if (propertyOption !== undefined) {
|
||||
item[customPropertyData.name as string] = propertyOption.label;
|
||||
delete item[key];
|
||||
json[customPropertyData.name as string] = propertyOption.label;
|
||||
delete json[key];
|
||||
}
|
||||
// type multioptions
|
||||
} 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
|
||||
.filter((option) => selectedIds.includes(option.id.toString()))
|
||||
.map((option) => option.label);
|
||||
item[customPropertyData.name] = selectedLabels;
|
||||
delete item[key];
|
||||
json[customPropertyData.name] = selectedLabels;
|
||||
delete json[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
item.json = json;
|
||||
}
|
||||
|
||||
export function sortOptionParameters(
|
||||
|
|
|
@ -4900,7 +4900,7 @@ export class Pipedrive implements INodeType {
|
|||
|
||||
if (customProperties !== undefined) {
|
||||
for (const item of returnData) {
|
||||
await pipedriveResolveCustomProperties(customProperties, item);
|
||||
pipedriveResolveCustomProperties(customProperties, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue