@pipedream/salesforce_rest_api 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
You can install the Pipedream Salesforce app in the [Accounts](https://pipedream.com/accounts) section of your account, or directly in a workflow.
|
|
4
|
+
|
|
5
|
+
### Webhooks
|
|
6
|
+
|
|
7
|
+
If you happen to stumble on the error: `UNKNOWN_EXCEPTION: admin operation already in progress` when creating an **Instant** trigger, you can follow the steps below to use the Salesforce Flow Builder to be able to use webhooks with Pipedream. This is a known error in Salesforce.
|
|
8
|
+
|
|
9
|
+
1. Create a New Workflow on [Pipedream](https://pipedream.com) and [add a HTTP trigger](https://pipedream.com/docs/workflows/steps/triggers/#http).
|
|
10
|
+
2. Login and go to your [Salesforce Setup Menu Page](https://help.salesforce.com/s/articleView?id=sf.basics_nav_setup.htm&type=5).
|
|
11
|
+
3. On the left hand Quick Find Bar, search for **Outbound Messages** in **Process Automation -> Workflow Actions**.
|
|
12
|
+
4. Click on the **New Outbound Message** button in the middle of the page.
|
|
13
|
+
5. Select the **Object Type** and click **Next**.
|
|
14
|
+
6. Fill in the **Name, Unique Name, and Available Fields to Send** fields in the form. On the **Endpoint URL** field, paste the **URL endpoint** generated by the HTTP trigger created earlier and then click **Save**.
|
|
15
|
+
7. Back to the left hand Quick Find Bar, search for **Flows** in **Process Automation**.
|
|
16
|
+
8. Click on **New Flow** button on the upper right hand corner and then select on **Record-Trigged Flow** and click on Create.
|
|
17
|
+
9. Select the same **Object Type** as before and select the appropriate flow trigger.
|
|
18
|
+
10. Optionally set **Entry Conditions**, keep **Actions and Related Records** selected, and click on **Done**.
|
|
19
|
+
11. Click on the plus sign below the newly created trigger and click on **Action**.
|
|
20
|
+
12. Search for **Outbound Message** and on the search bar select the trigger that was created previously.
|
|
21
|
+
13. Insert a **Label** and an **API Name** and then click on **Done**.
|
|
22
|
+
14. Save the flow by clicking on the **Save** button, insert a **Flow Label** and a **Flow API Name** and then click on **Activate** next to the Save button.
|
|
23
|
+
15. Back to the Pipedream Workflow, create a new step with the **Salesforce Convert SOAP Object** action.
|
|
24
|
+
16. In the **XML Soap Object** field, select the path from the trigger or type in `{{steps.trigger.event.body}}`.
|
|
25
|
+
17. That's it! You can now deploy the workflow and you will receive instant updates from Salesforce.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import salesforce_rest_api from "../../salesforce_rest_api.app.mjs";
|
|
2
|
+
import converter from "../../../helper_functions/actions/xml-to-json/xml-to-json.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "salesforce_rest_api-convert-soap-xml-to-json",
|
|
6
|
+
name: "Convert SOAP XML Object to JSON",
|
|
7
|
+
description: "Converts a SOAP XML Object received from Salesforce to JSON",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
salesforce_rest_api,
|
|
12
|
+
xml: {
|
|
13
|
+
type: "string",
|
|
14
|
+
label: "XML Soap Object",
|
|
15
|
+
description: "The object received from Salesforce that will be converted.",
|
|
16
|
+
},
|
|
17
|
+
extractNotificationOnly: {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
label: "Extract Notifications Only",
|
|
20
|
+
description: "Extracts only the notification parts from the XML. Default: `true`.",
|
|
21
|
+
optional: true,
|
|
22
|
+
default: true,
|
|
23
|
+
},
|
|
24
|
+
failOnError: {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
label: "Fail on Error",
|
|
27
|
+
description: "If should fail on error when extracting notifications. Default: `false`.",
|
|
28
|
+
optional: true,
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const json = await converter.run.bind({
|
|
34
|
+
input: this.xml,
|
|
35
|
+
compact: false,
|
|
36
|
+
})({
|
|
37
|
+
$,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!this.extractNotificationOnly) {
|
|
41
|
+
return json;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const notifications = json.elements[0].elements[0].elements[0].elements
|
|
46
|
+
.filter(({ name }) => name === "Notification");
|
|
47
|
+
return {
|
|
48
|
+
notifications,
|
|
49
|
+
};
|
|
50
|
+
} catch (e) {
|
|
51
|
+
const errorMessage = "Successfully converted to JSON, but was unable to extract notifications";
|
|
52
|
+
if (this.failOnError) {
|
|
53
|
+
$.export("$summary", errorMessage); // overrides exported $summary in converter
|
|
54
|
+
throw new Error(errorMessage);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
$.export("$summary", `${errorMessage}. Will return the whole JSON.`);
|
|
58
|
+
return json;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import startCase from "lodash/startCase.js";
|
|
2
|
-
|
|
3
2
|
import common from "../common-instant.mjs";
|
|
4
3
|
|
|
5
4
|
export default {
|
|
@@ -8,7 +7,29 @@ export default {
|
|
|
8
7
|
name: "New Object (Instant, of Selectable Type)",
|
|
9
8
|
key: "salesforce_rest_api-new-object-instant",
|
|
10
9
|
description: "Emit new event immediately after an object of arbitrary type (selected as an input parameter by the user) is created",
|
|
11
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.2",
|
|
11
|
+
hooks: {
|
|
12
|
+
...common.hooks,
|
|
13
|
+
async deploy() {
|
|
14
|
+
const objectType = this.objectType;
|
|
15
|
+
const nameField = await this.salesforce.getNameFieldForObjectType(objectType);
|
|
16
|
+
this.setNameField(nameField);
|
|
17
|
+
|
|
18
|
+
// emit hisorical events
|
|
19
|
+
const { recentItems } = await this.salesforce.listSObjectTypeIds(objectType);
|
|
20
|
+
const ids = recentItems.map((item) => item.Id);
|
|
21
|
+
for (const id of ids.slice(-25)) {
|
|
22
|
+
const object = await this.salesforce.getSObject(objectType, id);
|
|
23
|
+
const event = {
|
|
24
|
+
body: {
|
|
25
|
+
"New": object,
|
|
26
|
+
"UserId": id,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
this.processEvent(event);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
12
33
|
methods: {
|
|
13
34
|
...common.methods,
|
|
14
35
|
generateMeta(data) {
|