Skip to content

Commit abedb1e

Browse files
authored
Create a new Get New and Updated objects trigger (#50)
1 parent 8ca6f63 commit abedb1e

15 files changed

+2743
-960
lines changed

.circleci/config.yml

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,82 +13,82 @@ commands:
1313
event: fail
1414
custom: |
1515
{
16-
"blocks": [
17-
{
18-
"type": "section",
19-
"fields": [
20-
{
21-
"type": "mrkdwn",
22-
"text": ":red_circle: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* build failed"
23-
}
24-
]
25-
},
26-
{
27-
"type": "actions",
28-
"elements": [
29-
{
30-
"type": "button",
31-
"text": {
32-
"type": "plain_text",
33-
"text": "View Job"
34-
},
35-
"url": "${CIRCLE_BUILD_URL}"
36-
}
37-
]
38-
}
39-
]
16+
"blocks": [
17+
{
18+
"type": "section",
19+
"fields": [
20+
{
21+
"type": "mrkdwn",
22+
"text": ":red_circle: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* build failed"
23+
}
24+
]
25+
},
26+
{
27+
"type": "actions",
28+
"elements": [
29+
{
30+
"type": "button",
31+
"text": {
32+
"type": "plain_text",
33+
"text": "View Job"
34+
},
35+
"url": "${CIRCLE_BUILD_URL}"
36+
}
37+
]
38+
}
39+
]
4040
}
4141
notify_on_pass:
4242
steps:
4343
- slack/notify:
4444
event: pass
4545
custom: |
4646
{
47-
"blocks": [
48-
{
49-
"type": "section",
50-
"fields": [
51-
{
52-
"type": "mrkdwn",
53-
"text": ":tada: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* was successfully built and published"
54-
}
55-
]
56-
},
57-
{
58-
"type": "actions",
59-
"elements": [
60-
{
61-
"type": "button",
62-
"text": {
63-
"type": "plain_text",
64-
"text": "View Job"
65-
},
66-
"url": "${CIRCLE_BUILD_URL}"
67-
}
68-
]
69-
}
70-
]
47+
"blocks": [
48+
{
49+
"type": "section",
50+
"fields": [
51+
{
52+
"type": "mrkdwn",
53+
"text": ":tada: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* was successfully built and published"
54+
}
55+
]
56+
},
57+
{
58+
"type": "actions",
59+
"elements": [
60+
{
61+
"type": "button",
62+
"text": {
63+
"type": "plain_text",
64+
"text": "View Job"
65+
},
66+
"url": "${CIRCLE_BUILD_URL}"
67+
}
68+
]
69+
}
70+
]
7171
}
7272
jobs:
7373
test:
74-
docker: # run the steps with Docker
75-
- image: cimg/base:stable
74+
docker:
75+
- image: circleci/node:16-stretch
7676
steps:
7777
- checkout
7878
- node/install:
7979
node-version: << pipeline.parameters.node-version >>
80-
- node/install-packages:
81-
cache-path: ./node_modules
82-
override-ci-command: npm install
8380
- run:
8481
name: Audit Dependencies
8582
command: npm audit --production --audit-level=high
83+
- node/install-packages:
84+
cache-path: ./node_modules
85+
override-ci-command: npm install
8686
- run:
87-
name: test
87+
name: Running Mocha Tests
8888
command: npm test
8989
build:
9090
docker:
91-
- image: cimg/base:stable
91+
- image: circleci/node:16-stretch
9292
user: root
9393
steps:
9494
- checkout
@@ -122,4 +122,4 @@ workflows:
122122
branches:
123123
ignore: /.*/
124124
tags:
125-
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
125+
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/

.eslintrc.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ module.exports = {
44
es6: true,
55
mocha: true,
66
},
7-
extends: [
8-
'airbnb-base',
9-
],
7+
extends: 'airbnb-base',
8+
parser: 'babel-eslint',
109
rules: {
1110
'no-await-in-loop': 0,
12-
'max-len': ['error', { code: 150 }],
11+
'max-len': 0,
12+
'no-restricted-syntax': 0,
13+
'no-plusplus': 0,
1314
},
1415
};

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.4.0 (August 30, 2022)
2+
* New `Get New and Updated Objects Polling` trigger, old one set to deprecated
3+
* Update Sailor version to 2.6.29
4+
* Get rid of vulnerabilities in dependencies
5+
* Update component-commons-library version to 3.0.2
6+
17
## 2.3.0 (June 17, 2022)
28
* Added new `Type Of Search` - `External IDs` to `Upsert Object` action
39
* Implemented caching for metadata in `Upsert Object` action (metadata needs to find fields that contain attachment)

README.md

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
* [Environment variables](#environment-variables)
1010
* [Credentials](#credentials)
1111
* [Triggers](#triggers)
12-
* [Get New and Updated Objects Polling](#get-new-and-updated-objects-polling)
12+
* [Get Updated Objects Polling](#get-updated-objects-polling)
1313
* [Query Trigger](#query-trigger)
1414
* [Subscribe to platform events (REALTIME FLOWS ONLY)](#subscribe-to-platform-events-realtime-flows-only)
15+
* [Deprecated triggers](#deprecated-triggers)
1516
* [Actions](#actions)
1617
* [Bulk Create/Update/Delete/Upsert](#bulk-createupdatedeleteupsert)
1718
* [Bulk Query](#bulk-query)
@@ -69,6 +70,58 @@ Field name|Mandatory|Description|
6970
- click on ``Save`` button for saving your credentials
7071

7172
## Triggers
73+
74+
### Get Updated Objects Polling
75+
### Config Fields
76+
* **Object Type** Dropdown: Indicates Object Type to be fetched
77+
* **Include linked objects** Multiselect dropdown: list with all the related child and parent objects of the selected object type. List entries are given as `Object Name/Reference To (Relationship Name)`. Select one or more related objects, which will be join queried and included in the response from your Salesforce Organization. Please see the **Limitations** section below for use case advisories.
78+
* **Emit behavior** Dropdown: Indicates emit objects individually or emit by page
79+
* **Start Time** - TextField (string, optional): Indicates the beginning time to start retrieving events from in ISO 8601 Date time utc format - YYYY-MM-DDThh:mm:ssZ
80+
* **End Time** - TextField (string, optional, defaults to never): If provided, don’t fetch records modified after this time in ISO 8601 Date time utc format - YYYY-MM-DDThh:mm:ssZ
81+
* **Size of Polling Page** - TextField (optional, positive integer, max 10000, defaults to 10000): Indicates the size of pages to be fetched
82+
* **Process Single Page Per Execution** - Checkbox: Indicates that if the number of changed records exceeds the maximum number of results in a page, instead of fetching the next page immediately, wait until the next flow start to fetch the next page
83+
84+
#### Output Metadata
85+
- For `Fetch page`: An object with key ***results*** that has an array as its value
86+
- For `Emit Individually`: Each object fill the entire message
87+
88+
### Limitations
89+
* If records reach `Size of Polling Page` flow will find largest update date and use it as `Start Time` for next iterations, results with this date will be excluded from that iteration and include in the next one.
90+
* If all records from one iteration will have same 'LastModifiedDate' they will be proceed, but all objects in the next iteration will start from date strictly greater than this, to avoid this use bigger `Size of Polling Page`
91+
* Highly not recommended use very small (less than 5) `Size of Polling Page` (look at previous point)
92+
* When a binary field (primitive type `base64`, e.g. Documents, Attachments, etc) is selected on **Include linked objects**, an error will be thrown: `MALFORMED_QUERY: Binary fields cannot be selected in join queries. Instead of querying objects with binary fields as linked objects (such as children Attachments), try querying them directly.` There is also a limit to the number of linked objects that you can query at once - beyond two or three, depending on the number of fields in the linked objects, Salesforce could potentially return a Status Code 431 or 414 error, meaning the query is too long. Finally, due to a bug with multiselect dropdowns, it is recommended to deselect all of the elements in this field before you change your selection in the *Object* dropdown list.
93+
94+
### Query Trigger
95+
Continuously runs the same SOQL Query and emits results according to ``Output method`` configuration field.
96+
Use the Salesforce Object Query Language (SOQL) to search your organization’s Salesforce data for specific information.
97+
SOQL is similar to the SELECT statement in the widely used Structured Query Language (SQL) but is designed specifically for Salesforce data.
98+
This trigger allows you to interact with your data using SOQL.
99+
100+
#### List of Expected Config fields
101+
102+
* **SOQL Query** - Input field for your SOQL Query
103+
* **Output method** - dropdown list with options: `Emit all` - all found records will be emitted in one array `records`, and `Emit individually` - each found object will be emitted individual. Optional field, defaults to: `Emit individually`.
104+
105+
### Subscribe to platform events (REALTIME FLOWS ONLY)
106+
This trigger will subscribe for any platform Event using Salesforce streaming API.
107+
108+
#### Input field description
109+
* **Event object name** - Input field where you should select the type of platform event which you want to subscribe E.g. `My platform event`
110+
111+
#### How to create new custom Platform event Entity:
112+
`Setup --> Integrations --> Platform Events --> New Platform Event`
113+
![Screenshot from 2019-03-11 11-51-10](https://user-images.githubusercontent.com/13310949/54114889-1088e900-43f4-11e9-8b49-3a8113b6577d.png)
114+
115+
You can find more detail information in the [Platform Events Intro Documentation](https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_intro.htm).
116+
117+
#### Limitations:
118+
At the moment this trigger can be used only for **"Realtime"** flows.
119+
120+
### Deprecated triggers
121+
122+
<details>
123+
<summary>Get New and Updated Objects Polling</summary>
124+
72125
### Get New and Updated Objects Polling
73126
Polls existing and updated objects. You can select any custom or built-in object for your Salesforce instance.
74127

@@ -83,6 +136,7 @@ Polls existing and updated objects. You can select any custom or built-in object
83136
* **Include linked objects** - Multiselect dropdown list with all the related child and parent objects of the selected object type. List entries are given as `Object Name/Reference To (Relationship Name)`. Select one or more related objects, which will be join queried and included in the response from your Salesforce Organization. Please see the **Limitations** section below for use case advisories.
84137
* **Output method** - dropdown list with options: `Emit all` - all found records will be emitted in one array `records`, and `Emit individually` - each found object will be emitted individual. Optional field, defaults to: `Emit individually`.
85138
* **Max Fetch Count** - limit for a number of messages that can be fetched. 1,000 is the default value when the variable is not set.
139+
86140
For example, you have 234 “Contact” objects, 213 of them were changed from 2019-01-01.
87141
You want to select all “Contacts” that were changed from 2019-01-01, set the page size to 100 and process single page per execution.
88142
For you purpose you need to specify following fields:
@@ -99,31 +153,7 @@ If you select `no` in **Process single page per execution**, all 213 contacts wi
99153
#### Limitations
100154
When a binary field (primitive type `base64`, e.g. Documents, Attachments, etc) is selected on **Include linked objects**, an error will be thrown: 'MALFORMED_QUERY: Binary fields cannot be selected in join queries. Instead of querying objects with binary fields as linked objects (such as children Attachments), try querying them directly.' There is also a limit to the number of linked objects that you can query at once - beyond two or three, depending on the number of fields in the linked objects, Salesforce could potentially return a Status Code 431 or 414 error, meaning the query is too long. Finally, due to a bug with multiselect dropdowns, it is recommended to deselect all of the elements in this field before you change your selection in the *Object* dropdown list.
101155

102-
### Query Trigger
103-
Continuously runs the same SOQL Query and emits results according to ``Output method`` configuration field.
104-
Use the Salesforce Object Query Language (SOQL) to search your organization’s Salesforce data for specific information.
105-
SOQL is similar to the SELECT statement in the widely used Structured Query Language (SQL) but is designed specifically for Salesforce data.
106-
This trigger allows you to interact with your data using SOQL.
107-
108-
#### List of Expected Config fields
109-
110-
* **SOQL Query** - Input field for your SOQL Query
111-
* **Output method** - dropdown list with options: `Emit all` - all found records will be emitted in one array `records`, and `Emit individually` - each found object will be emitted individual. Optional field, defaults to: `Emit individually`.
112-
113-
### Subscribe to platform events (REALTIME FLOWS ONLY)
114-
This trigger will subscribe for any platform Event using Salesforce streaming API.
115-
116-
#### Input field description
117-
* **Event object name** - Input field where you should select the type of platform event which you want to subscribe E.g. `My platform event`
118-
119-
#### How to create new custom Platform event Entity:
120-
`Setup --> Integrations --> Platform Events --> New Platform Event`
121-
![Screenshot from 2019-03-11 11-51-10](https://user-images.githubusercontent.com/13310949/54114889-1088e900-43f4-11e9-8b49-3a8113b6577d.png)
122-
123-
You can find more detail information in the [Platform Events Intro Documentation](https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_intro.htm).
124-
125-
#### Limitations:
126-
At the moment this trigger can be used only for **"Realtime"** flows.
156+
</details>
127157

128158
## Actions
129159
### Bulk Create/Update/Delete/Upsert
@@ -277,6 +307,9 @@ This parameters can be changed by setting environment variables:
277307
* **HASH_LIMIT_TIME** - Hash expiration time in milis
278308
* **HASH_LIMIT_ELEMENTS** - Hash size number limit
279309

310+
#### Known limitations
311+
If `Output method` set to `Emit page` maximum "Page number" must be less or equal to "Page size"/2000
312+
280313
### Query Action
281314
Executing a SOQL Query that may return many objects.
282315
Use the Salesforce Object Query Language (SOQL) to search your organization’s Salesforce data for specific information.

component.json

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"description": "Customer relationship management (CRM) software & cloud computing from the leader in CRM solutions for businesses large & small.",
44
"docsUrl": "https://github.com/elasticio/salesforce-component-v2",
55
"url": "http://www.salesforce.com/",
6-
"buildType": "docker",
7-
"version": "2.3.0",
6+
"version": "2.4.0",
87
"authClientTypes": [
98
"oauth2"
109
],
@@ -32,9 +31,84 @@
3231
}
3332
},
3433
"triggers": {
34+
"getUpdatedObjectsPolling": {
35+
"main": "./lib/triggers/getUpdatedObjectsPolling.js",
36+
"title": "Get Updated Objects Polling",
37+
"type": "polling",
38+
"help": {
39+
"description": "Poll for updated objects",
40+
"link": "/test-component/#get-updated-objects-polling"
41+
},
42+
"fields": {
43+
"sobject": {
44+
"viewClass": "SelectView",
45+
"label": "Object Type",
46+
"order": 20,
47+
"required": true,
48+
"model": "objectTypes",
49+
"prompt": "Please select a Salesforce Object"
50+
},
51+
"linkedObjects": {
52+
"label": "Include linked objects",
53+
"viewClass": "MultiSelectView",
54+
"order": 15,
55+
"required": false,
56+
"require": [
57+
"sobject"
58+
],
59+
"help": {
60+
"description": "Linked objects that you can query at once - beyond two or three, depending on the number of fields in the linked objects."
61+
},
62+
"model": "linkedObjectTypes"
63+
},
64+
"emitBehavior": {
65+
"viewClass": "SelectView",
66+
"order": 12,
67+
"required": false,
68+
"label": "Emit Behavior",
69+
"prompt": "Select an output method. Defaults to: Emit individually",
70+
"model": {
71+
"emitIndividually": "Emit individually",
72+
"fetchPage": "Emit page"
73+
}
74+
},
75+
"startTime": {
76+
"viewClass": "TextFieldView",
77+
"label": "Start Time",
78+
"order": 10,
79+
"required": false,
80+
"placeholder": "1970-01-01T00:00:00.000Z",
81+
"note": "Indicates the beginning time to start polling from, default 1970-01-01T00:00:00.000Z"
82+
},
83+
"endTime": {
84+
"viewClass": "TextFieldView",
85+
"label": "End Time",
86+
"order": 8,
87+
"required": false,
88+
"placeholder": "3000-01-01T00:00:00.000Z",
89+
"note": "If provided, do not fetch records modified after this time (defaults to execution time)"
90+
},
91+
"pageSize": {
92+
"required": false,
93+
"viewClass": "TextFieldView",
94+
"order": 7,
95+
"label": "Size of Polling Page",
96+
"placeholder": "10000",
97+
"note": "Number of records to be fetched (defaults to 10000). Positive integer only, max 10000 objects"
98+
},
99+
"singlePagePerInterval": {
100+
"viewClass": "CheckBoxView",
101+
"order": 4,
102+
"label": "Process Single Page Per Execution",
103+
"note": "Indicates that if the number of changed records exceeds the maximum number of results in a page, instead of fetching the next page immediately, wait until the next flow start to fetch the next page."
104+
}
105+
},
106+
"dynamicMetadata": true
107+
},
35108
"entry": {
36109
"title": "Get New and Updated Objects Polling",
37110
"main": "./lib/entry.js",
111+
"deprecated": true,
38112
"order": 99,
39113
"help": {
40114
"description": "Will poll for existing and updated objects where you can select any custom or build-in object for your Salesforce instance",

0 commit comments

Comments
 (0)