Skip to content

Commit 71539e2

Browse files
committed
issue 18484
1 parent 885e22a commit 71539e2

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

components/salesforce_rest_api/sources/common/common-updated-record.mjs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ export default {
1212
const nameField = await this.salesforce.getNameFieldForObjectType(objectType);
1313
this.setNameField(nameField);
1414

15-
// emit historical events
16-
const { recentItems } = await this.salesforce.listSObjectTypeIds(objectType);
17-
const ids = recentItems.map((item) => item.Id);
18-
for (const id of ids.slice(-25)) {
19-
const object = await this.salesforce.getSObject(objectType, id);
20-
const event = {
21-
body: {
22-
"New": object,
23-
"UserId": id,
24-
},
25-
};
26-
const meta = this.generateWebhookMeta(event);
27-
this.$emit(event.body, meta);
15+
if (!this.skipFirstRun) {
16+
const { recentItems } = await this.salesforce.listSObjectTypeIds(objectType);
17+
const ids = recentItems.map((item) => item.Id);
18+
for (const id of ids.slice(-25)) {
19+
const object = await this.salesforce.getSObject(objectType, id);
20+
const event = {
21+
body: {
22+
"New": object,
23+
"UserId": id,
24+
},
25+
};
26+
const meta = this.generateWebhookMeta(event);
27+
this.$emit(event.body, meta);
28+
}
2829
}
2930
},
3031
async activate() {

components/salesforce_rest_api/sources/common/common.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,15 @@ export default {
165165
console.log("Ignoring timer event (webhook active)");
166166
return;
167167
}
168+
168169
const startTimestamp = this.getLatestDateCovered();
170+
171+
if (this.skipFirstRun && !startTimestamp) {
172+
const now = new Date().toISOString();
173+
this.setLatestDateCovered(now);
174+
return;
175+
}
176+
169177
const endTimestamp = new Date(event.timestamp * 1000).toISOString();
170178
const timeDiffSec = Math.floor(
171179
(Date.parse(endTimestamp) - Date.parse(startTimestamp)) / 1000,

components/salesforce_rest_api/sources/record-updated-instant/record-updated-instant.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export default {
2424
optional: true,
2525
description: "If specified, events will only be emitted if at least one of the selected fields is updated. This filter is only available when a webhook is created successfully.",
2626
},
27+
skipFirstRun: {
28+
type: "boolean",
29+
label: "Skip existing records when first activated",
30+
description: "When enabled, this trigger will ignore all existing records and only watch for updates that happen after activation. When disabled, it will process existing records on first run.",
31+
optional: true,
32+
default: false,
33+
},
2734
},
2835
methods: {
2936
...common.methods,

0 commit comments

Comments
 (0)