Skip to content

Commit 7e7e5df

Browse files
committed
update search-crm
1 parent 194d1ef commit 7e7e5df

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

components/hubspot/actions/search-crm/search-crm.mjs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
name: "Search CRM",
1919
description:
2020
"Search companies, contacts, deals, feedback submissions, products, tickets, line-items, quotes, leads, or custom objects. [See the documentation](https://developers.hubspot.com/docs/api/crm/search)",
21-
version: "1.0.12",
21+
version: "1.0.13",
2222
type: "action",
2323
props: {
2424
hubspot,
@@ -42,6 +42,13 @@ export default {
4242
"Set to `true` to search for an exact match of the search value. If `false`, partial matches will be returned. Default: `true`",
4343
default: true,
4444
optional: true,
45+
reloadProps: true,
46+
},
47+
createdAfter: {
48+
type: "string",
49+
label: "Created After",
50+
description: "Filter results to only include objects created after this date. Example: `2023-03-03T16:16:24.400Z`. Recommended when `Exact Match` is set to `false`.",
51+
optional: true,
4552
},
4653
createIfNotFound: {
4754
type: "boolean",
@@ -56,6 +63,14 @@ export default {
5663
async additionalProps() {
5764
const props = {};
5865

66+
if (this.exactMatch === false && !this.createdAfter) {
67+
props.exactMatchAlert = {
68+
type: "alert",
69+
alertType: "info",
70+
content: "It is recommended to set `Created After` when `Exact Match` is set to `false` to avoid potential timeouts.",
71+
};
72+
}
73+
5974
if (this.objectType === "custom_object") {
6075
try {
6176
props.customObjectType = {
@@ -225,9 +240,9 @@ export default {
225240
);
226241
},
227242
async paginate(params) {
228-
let results;
243+
let results, done = false;
229244
const items = [];
230-
while (!results || params.after) {
245+
while ((!results || params.after) && !done) {
231246
results = await this.hubspot.searchCRM(params);
232247
if (results.paging) {
233248
params.after = results.paging.next.after;
@@ -236,6 +251,12 @@ export default {
236251
}
237252
results = results.results;
238253
for (const result of results) {
254+
if (this.createdAfter
255+
&& Date.parse(result.properties.createdate) <= Date.parse(this.createdAfter)
256+
) {
257+
done = true;
258+
break;
259+
}
239260
items.push(result);
240261
}
241262
}
@@ -252,6 +273,8 @@ export default {
252273
searchValue,
253274
exactMatch,
254275
/* eslint-disable no-unused-vars */
276+
createdAfter,
277+
exactMatchAlert,
255278
info,
256279
createIfNotFound,
257280
creationProps,
@@ -282,6 +305,13 @@ export default {
282305
properties: [
283306
...defaultProperties,
284307
...additionalProperties,
308+
searchProperty,
309+
],
310+
sorts: [
311+
{
312+
propertyName: "createdate",
313+
direction: "DESCENDING",
314+
},
285315
],
286316
};
287317
if (exactMatch) {

components/hubspot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/hubspot",
3-
"version": "1.7.3",
3+
"version": "1.7.4",
44
"description": "Pipedream Hubspot Components",
55
"main": "hubspot.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)