diff --git a/packages/nodes-base/nodes/Hubspot/ContactDescription.ts b/packages/nodes-base/nodes/Hubspot/ContactDescription.ts
index 60d2be5d70..015f3d30cf 100644
--- a/packages/nodes-base/nodes/Hubspot/ContactDescription.ts
+++ b/packages/nodes-base/nodes/Hubspot/ContactDescription.ts
@@ -40,6 +40,11 @@ export const contactOperations = [
value: 'getRecentlyCreatedUpdated',
description: 'Get recently created/updated contacts',
},
+ {
+ name: 'Search',
+ value: 'search',
+ description: 'Search contacts',
+ },
],
default: 'upsert',
description: 'The operation to perform.',
@@ -834,4 +839,262 @@ export const contactFields = [
},
],
},
+
+//*-------------------------------------------------------------------------- */
+/* contact:search */
+/* -------------------------------------------------------------------------- */
+ {
+ displayName: 'Return All',
+ name: 'returnAll',
+ type: 'boolean',
+ displayOptions: {
+ show: {
+ resource: [
+ 'contact',
+ ],
+ operation: [
+ 'search',
+ ],
+ },
+ },
+ default: false,
+ description: 'If all results should be returned or only up to a given limit.',
+ },
+ {
+ displayName: 'Limit',
+ name: 'limit',
+ type: 'number',
+ displayOptions: {
+ show: {
+ resource: [
+ 'contact',
+ ],
+ operation: [
+ 'search',
+ ],
+ returnAll: [
+ false,
+ ],
+ },
+ },
+ typeOptions: {
+ minValue: 1,
+ maxValue: 250,
+ },
+ default: 100,
+ description: 'How many results to return.',
+ },
+ {
+ displayName: 'Sort By',
+ name: 'sorts',
+ type: 'options',
+ typeOptions: {
+ loadOptionsMethod: 'getContactProperties',
+ },
+ displayOptions: {
+ show: {
+ resource: [
+ 'contact',
+ ],
+ operation: [
+ 'search',
+ ],
+ },
+ },
+ default: [],
+ },
+ {
+ displayName: 'Direction',
+ name: 'direction',
+ type: 'options',
+ options: [
+ {
+ name: 'ASC',
+ value: 'ASCENDING',
+ },
+ {
+ name: 'DESC',
+ value: 'DESCENDING',
+ },
+ ],
+ displayOptions: {
+ show: {
+ resource: [
+ 'contact',
+ ],
+ operation: [
+ 'search',
+ ],
+ },
+ },
+ default: 'DESCENDING',
+ description: 'Defines the direction in which search results are ordered. Default value is DESC.',
+ },
+ {
+ displayName: 'Filter Groups',
+ name: 'filterGroupsUi',
+ type: 'fixedCollection',
+ default: '',
+ placeholder: 'Add Filter Group',
+ typeOptions: {
+ multipleValues: true,
+ },
+ required: false,
+ displayOptions: {
+ show: {
+ resource: [
+ 'contact',
+ ],
+ operation: [
+ 'search',
+ ],
+ },
+ },
+ options: [
+ {
+ name: 'filterGroupsValues',
+ displayName: 'Filter Group',
+ values: [
+ {
+ displayName: 'Filters',
+ name: 'filtersUi',
+ type: 'fixedCollection',
+ default: '',
+ placeholder: 'Add Filter',
+ typeOptions: {
+ multipleValues: true,
+ },
+ required: false,
+ options: [
+ {
+ name: 'filterValues',
+ displayName: 'Filter',
+ values: [
+ {
+ displayName: 'Property Name',
+ name: 'propertyName',
+ type: 'options',
+ typeOptions: {
+ loadOptionsMethod: 'getContactProperties',
+ },
+ default: '',
+ },
+ {
+ displayName: 'Operator',
+ name: 'operator',
+ type: 'options',
+ options: [
+ {
+ name: 'Equal',
+ value: 'EQ',
+ },
+ {
+ name: 'Not Equal',
+ value: 'NEQ',
+ },
+ {
+ name: 'Less Than',
+ value: 'LT',
+ },
+ {
+ name: 'Less Than Or Equal',
+ value: 'LTE',
+ },
+ {
+ name: 'Greater Than',
+ value: 'GT',
+ },
+ {
+ name: 'Greater Than Or Equal',
+ value: 'GTE',
+ },
+ {
+ name: 'Is Known',
+ value: 'HAS_PROPERTY',
+ },
+ {
+ name: 'Is Unknown',
+ value: 'NOT_HAS_PROPERTY',
+ },
+ {
+ name: 'Contains Exactly',
+ value: 'CONSTAIN_TOKEN',
+ },
+ {
+ name: `Doesn't Contain Exactly`,
+ value: 'NOT_CONSTAIN_TOKEN',
+ },
+ ],
+ default: 'EQ',
+ },
+ {
+ displayName: 'Value',
+ name: 'value',
+ displayOptions: {
+ hide: {
+ operator: [
+ 'HAS_PROPERTY',
+ 'NOT_HAS_PROPERTY',
+ ],
+ },
+ },
+ type: 'string',
+ default: '',
+ },
+ ],
+ }
+ ],
+ description: 'Use filters to limit the results to only CRM objects with matching property values. More info here',
+ },
+ ],
+ }
+ ],
+ description: `When multiple filters are provided within a filterGroup, they will be combined using a logical AND operator.
+ When multiple filterGroups are provided, they will be combined using a logical OR operator.
+ The system supports a maximum of three filterGroups with up to three filters each.
+ More info here`
+ },
+ {
+ displayName: 'Additional Fields',
+ name: 'additionalFields',
+ type: 'collection',
+ placeholder: 'Add Field',
+ default: {},
+ displayOptions: {
+ show: {
+ resource: [
+ 'contact',
+ ],
+ operation: [
+ 'search',
+ ],
+ },
+ },
+ options: [
+ {
+ displayName: 'Fields',
+ name: 'properties',
+ type: 'multiOptions',
+ typeOptions: {
+ loadOptionsMethod: 'getContactProperties',
+ },
+ default: [
+ 'firstname',
+ 'lastname',
+ 'email',
+ ],
+ description: `Used to include specific company properties in the results.
+ By default, the results will only include company ID and will not include the values for any properties for your companys.
+ Including this parameter will include the data for the specified property in the results.
+ You can include this parameter multiple times to request multiple properties separed by ,.`,
+ },
+ {
+ displayName: 'Query',
+ name: 'query',
+ type: 'string',
+ default: '',
+ description: 'Perform a text search against all property values for an object type',
+ },
+ ],
+ },
] as INodeProperties[];
diff --git a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts
index 458a974837..c6cb238903 100644
--- a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts
+++ b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts
@@ -1166,6 +1166,53 @@ export class Hubspot implements INodeType {
const endpoint = `/contacts/v1/contact/vid/${contactId}`;
responseData = await hubspotApiRequest.call(this, 'DELETE', endpoint);
}
+ //https://developers.hubspot.com/docs/api/crm/search
+ if (operation === 'search') {
+ const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
+ const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
+ const filtersGroupsUi = this.getNodeParameter('filterGroupsUi', i) as IDataObject;
+ const sorts = this.getNodeParameter('sorts', i) as string;
+ const direction = this.getNodeParameter('direction', i) as string;
+
+ const body: IDataObject = {
+ sorts: [
+ {
+ propertyName: sorts,
+ direction,
+ },
+ ],
+ };
+
+ if (filtersGroupsUi) {
+ const filterGroupValues = (filtersGroupsUi as IDataObject).filterGroupsValues as IDataObject[];
+ if (filterGroupValues) {
+ body.filterGroups = [];
+ for (const filterGroupValue of filterGroupValues) {
+ if (filterGroupValue.filtersUi) {
+ const filterValues = (filterGroupValue.filtersUi as IDataObject).filterValues as IDataObject[];
+ if (filterValues) {
+ //@ts-ignore
+ body.filterGroups.push({ filters: filterValues });
+ }
+ }
+ }
+ }
+ }
+
+ Object.assign(body, additionalFields);
+
+ const endpoint = '/crm/v3/objects/contacts/search';
+
+ if (returnAll) {
+
+ responseData = await hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body, qs);
+
+ } else {
+ qs.count = this.getNodeParameter('limit', 0) as number;
+ responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body, qs);
+ responseData = responseData.results;
+ }
+ }
}
//https://developers.hubspot.com/docs/methods/companies/companies-overview
if (resource === 'company') {