@pipedream/salesforce_rest_api 1.9.2 → 1.10.0
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.
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "salesforce_rest_api-get-record-by-id",
|
|
5
|
+
name: "Get Record by ID",
|
|
6
|
+
description: "Retrieves a record by its ID. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
salesforce,
|
|
16
|
+
sobjectType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
salesforce,
|
|
19
|
+
"objectType",
|
|
20
|
+
],
|
|
21
|
+
description: "The type of object to retrieve a record of",
|
|
22
|
+
},
|
|
23
|
+
recordId: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
salesforce,
|
|
26
|
+
"recordId",
|
|
27
|
+
(c) => ({
|
|
28
|
+
objType: c.sobjectType,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
description: "The ID of the record to retrieve",
|
|
32
|
+
},
|
|
33
|
+
fieldsToObtain: {
|
|
34
|
+
propDefinition: [
|
|
35
|
+
salesforce,
|
|
36
|
+
"fieldsToObtain",
|
|
37
|
+
(c) => ({
|
|
38
|
+
objType: c.sobjectType,
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
async run({ $ }) {
|
|
44
|
+
let {
|
|
45
|
+
sobjectType,
|
|
46
|
+
recordId,
|
|
47
|
+
fieldsToObtain,
|
|
48
|
+
} = this;
|
|
49
|
+
|
|
50
|
+
if (typeof fieldsToObtain === "string") fieldsToObtain = fieldsToObtain.split(",");
|
|
51
|
+
|
|
52
|
+
let query = `SELECT ${fieldsToObtain.join(", ")} FROM ${sobjectType}`;
|
|
53
|
+
|
|
54
|
+
query += ` WHERE Id = '${recordId}'`;
|
|
55
|
+
|
|
56
|
+
const { records } = await this.salesforce.query({
|
|
57
|
+
$,
|
|
58
|
+
query,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
$.export("$summary", `Sucessfully retrieved record with ID ${recordId}`);
|
|
62
|
+
return records[0];
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "salesforce_rest_api-list-object-fields",
|
|
5
|
+
name: "List Object Fields",
|
|
6
|
+
description: "Lists all fields for a given object type. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_describe.htm)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
salesforce,
|
|
16
|
+
sobjectType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
salesforce,
|
|
19
|
+
"objectType",
|
|
20
|
+
],
|
|
21
|
+
description: "The type of object to list fields of",
|
|
22
|
+
},
|
|
23
|
+
customOnly: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
label: "Custom Only",
|
|
26
|
+
description: "Set to `true` to only list custom fields",
|
|
27
|
+
optional: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async run({ $ }) {
|
|
31
|
+
let response = await this.salesforce.getFieldsForObjectType(this.sobjectType);
|
|
32
|
+
|
|
33
|
+
if (this.customOnly) {
|
|
34
|
+
response = response.filter((field) => field.custom);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
$.export("$summary", `Successfully listed fields for object type ${this.sobjectType}`);
|
|
38
|
+
return response;
|
|
39
|
+
},
|
|
40
|
+
};
|