Skip to content

Commit

Permalink
fix(Notion Node): Handle empty values correctly for Notion selects + …
Browse files Browse the repository at this point in the history
…multi selects (#7383)

Github issue / Community forum post (link here to close automatically):
  • Loading branch information
elsmr authored Oct 9, 2023
1 parent 8187be1 commit fbcd1d4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/nodes-base/nodes/Notion/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ function getDateFormat(includeTime: boolean) {
return '';
}

function isEmpty(value: unknown): boolean {
return value === undefined || value === null || value === '';
}

function getPropertyKeyValue(
this: IExecuteFunctions,
value: any,
Expand Down Expand Up @@ -368,7 +372,16 @@ function getPropertyKeyValue(
};
break;
case 'multi_select':
if (isEmpty(value.multiSelectValue)) {
result = {
type: 'multi_select',
multi_select: [],
};
break;
}

const multiSelectValue = value.multiSelectValue;

result = {
type: 'multi_select',
multi_select: (Array.isArray(multiSelectValue)
Expand Down Expand Up @@ -403,6 +416,14 @@ function getPropertyKeyValue(
};
break;
case 'select':
if (isEmpty(value.selectValue)) {
result = {
type: 'select',
select: null,
};
break;
}

result = {
type: 'select',
select: version === 1 ? { id: value.selectValue } : { name: value.selectValue },
Expand Down

0 comments on commit fbcd1d4

Please sign in to comment.