@pipedream/salesforce_rest_api 1.3.1 → 1.5.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.
- package/actions/common/base-create-update.mjs +8 -5
- package/actions/create-account/create-account.mjs +1 -1
- package/actions/create-attachment/create-attachment.mjs +1 -1
- package/actions/create-campaign/create-campaign.mjs +1 -1
- package/actions/create-case/create-case.mjs +1 -1
- package/actions/create-casecomment/create-casecomment.mjs +1 -1
- package/actions/create-contact/create-contact.mjs +1 -1
- package/actions/create-content-note/create-content-note.mjs +91 -0
- package/actions/create-event/create-event.mjs +1 -1
- package/actions/create-lead/create-lead.mjs +1 -1
- package/actions/create-note/create-note.mjs +1 -1
- package/actions/create-opportunity/create-opportunity.mjs +1 -1
- package/actions/create-record/create-record.mjs +1 -1
- package/actions/create-task/create-task.mjs +1 -1
- package/actions/create-user/create-user.mjs +1 -1
- package/actions/update-account/update-account.mjs +1 -1
- package/actions/update-contact/update-contact.mjs +1 -1
- package/actions/update-opportunity/update-opportunity.mjs +1 -1
- package/actions/update-record/update-record.mjs +1 -1
- package/actions/upsert-record/upsert-record.mjs +120 -0
- package/common/sobjects/content-document-link.mjs +51 -0
- package/common/sobjects/content-note.mjs +34 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ export function getProps({
|
|
|
14
14
|
objType,
|
|
15
15
|
createOrUpdate = "create",
|
|
16
16
|
docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_concepts.htm",
|
|
17
|
+
showDocsInfo = true,
|
|
17
18
|
showDateInfo = false,
|
|
18
19
|
}) {
|
|
19
20
|
let { initialProps } = objType;
|
|
@@ -34,6 +35,13 @@ export function getProps({
|
|
|
34
35
|
|
|
35
36
|
return {
|
|
36
37
|
salesforce,
|
|
38
|
+
...showDocsInfo && {
|
|
39
|
+
docsInfo: {
|
|
40
|
+
type: "alert",
|
|
41
|
+
alertType: "info",
|
|
42
|
+
content: `[See the documentation](${docsLink}) for more information on available fields.`,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
37
45
|
...showDateInfo && {
|
|
38
46
|
dateInfo: {
|
|
39
47
|
type: "alert",
|
|
@@ -45,11 +53,6 @@ export function getProps({
|
|
|
45
53
|
? "createProps"
|
|
46
54
|
: "updateProps"],
|
|
47
55
|
...initialProps,
|
|
48
|
-
docsInfo: {
|
|
49
|
-
type: "alert",
|
|
50
|
-
alertType: "info",
|
|
51
|
-
content: `[See the documentation](${docsLink}) for more information on available fields.`,
|
|
52
|
-
},
|
|
53
56
|
useAdvancedProps: {
|
|
54
57
|
propDefinition: [
|
|
55
58
|
salesforce,
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "salesforce_rest_api-create-account",
|
|
9
9
|
name: "Create Account",
|
|
10
10
|
description: `Creates a Salesforce account. [See the documentation](${docsLink})`,
|
|
11
|
-
version: "0.3.
|
|
11
|
+
version: "0.3.1",
|
|
12
12
|
type: "action",
|
|
13
13
|
methods: {
|
|
14
14
|
...common.methods,
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
key: "salesforce_rest_api-create-attachment",
|
|
19
19
|
name: "Create Attachment",
|
|
20
20
|
description: `Creates an Attachment on a parent object. [See the documentation](${docsLink})`,
|
|
21
|
-
version: "0.4.
|
|
21
|
+
version: "0.4.1",
|
|
22
22
|
type: "action",
|
|
23
23
|
props,
|
|
24
24
|
async run({ $ }) {
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "salesforce_rest_api-create-campaign",
|
|
9
9
|
name: "Create Campaign",
|
|
10
10
|
description: `Creates a marketing campaign. [See the documentation](${docsLink})`,
|
|
11
|
-
version: "0.3.
|
|
11
|
+
version: "0.3.1",
|
|
12
12
|
type: "action",
|
|
13
13
|
methods: {
|
|
14
14
|
...common.methods,
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "salesforce_rest_api-create-case",
|
|
9
9
|
name: "Create Case",
|
|
10
10
|
description: `Creates a Case, which represents a customer issue or problem. [See the documentation](${docsLink})`,
|
|
11
|
-
version: "0.3.
|
|
11
|
+
version: "0.3.1",
|
|
12
12
|
type: "action",
|
|
13
13
|
methods: {
|
|
14
14
|
...common.methods,
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
key: "salesforce_rest_api-create-casecomment",
|
|
18
18
|
name: "Create Case Comment",
|
|
19
19
|
description: `Creates a Case Comment on a selected Case. [See the documentation](${docsLink})`,
|
|
20
|
-
version: "0.3.
|
|
20
|
+
version: "0.3.1",
|
|
21
21
|
type: "action",
|
|
22
22
|
props,
|
|
23
23
|
async run({ $ }) {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import common, { getProps } from "../common/base-create-update.mjs";
|
|
3
|
+
import contentNote from "../../common/sobjects/content-note.mjs";
|
|
4
|
+
import contentDocumentLink from "../../common/sobjects/content-document-link.mjs";
|
|
5
|
+
|
|
6
|
+
const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentnote.htm";
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
useAdvancedProps: contentNoteUseAdvancedProps,
|
|
10
|
+
...contentNoteProps
|
|
11
|
+
} = getProps({
|
|
12
|
+
objType: contentNote,
|
|
13
|
+
docsLink,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
useAdvancedProps: contentDocumentLinkUseAdvancedProps,
|
|
18
|
+
...contentDocumentLinkProps
|
|
19
|
+
} = getProps({
|
|
20
|
+
objType: contentDocumentLink,
|
|
21
|
+
docsLink,
|
|
22
|
+
showDocsInfo: false,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
...common,
|
|
27
|
+
key: "salesforce_rest_api-create-content-note",
|
|
28
|
+
name: "Create Content Note",
|
|
29
|
+
description: `Creates a content note. [See the documentation](${docsLink}) and [Set Up Notes](https://help.salesforce.com/s/articleView?id=sales.notes_admin_setup.htm&type=5).`,
|
|
30
|
+
version: "0.0.1",
|
|
31
|
+
type: "action",
|
|
32
|
+
props: {
|
|
33
|
+
...contentNoteProps,
|
|
34
|
+
...contentDocumentLinkProps,
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
...common.methods,
|
|
38
|
+
escapeHtml4(unsafe) {
|
|
39
|
+
return unsafe
|
|
40
|
+
.replace(/&/g, "&")
|
|
41
|
+
.replace(/</g, "<")
|
|
42
|
+
.replace(/>/g, ">")
|
|
43
|
+
.replace(/"/g, """)
|
|
44
|
+
.replace(/'/g, "'");
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
async run({ $ }) {
|
|
48
|
+
const {
|
|
49
|
+
salesforce,
|
|
50
|
+
escapeHtml4,
|
|
51
|
+
Title,
|
|
52
|
+
Content,
|
|
53
|
+
OwnerId,
|
|
54
|
+
LinkedEntityId,
|
|
55
|
+
ShareType,
|
|
56
|
+
Visibility,
|
|
57
|
+
} = this;
|
|
58
|
+
|
|
59
|
+
const contentNoteResponse = await salesforce.createRecord("ContentNote", {
|
|
60
|
+
$,
|
|
61
|
+
data: {
|
|
62
|
+
Title,
|
|
63
|
+
Content: Buffer.from(escapeHtml4(Content)).toString("base64"),
|
|
64
|
+
OwnerId: OwnerId,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (!LinkedEntityId) {
|
|
69
|
+
$.export("$summary", `Successfully created content note with ID \`${contentNoteResponse.id}\`.`);
|
|
70
|
+
return {
|
|
71
|
+
contentNote: contentNoteResponse,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const contentDocumentLinkResponse = await salesforce.createRecord("ContentDocumentLink", {
|
|
76
|
+
$,
|
|
77
|
+
data: {
|
|
78
|
+
ContentDocumentId: contentNoteResponse.id,
|
|
79
|
+
LinkedEntityId,
|
|
80
|
+
ShareType,
|
|
81
|
+
Visibility,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
$.export("$summary", `Successfully created content note with ID \`${contentNoteResponse.id}\` and document link with ID \`${contentDocumentLinkResponse.id}\`.`);
|
|
86
|
+
return {
|
|
87
|
+
contentNote: contentNoteResponse,
|
|
88
|
+
contentDocumentLink: contentDocumentLinkResponse,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "salesforce_rest_api-create-opportunity",
|
|
9
9
|
name: "Create Opportunity",
|
|
10
10
|
description: `Creates an opportunity. [See the documentation](${docsLink})`,
|
|
11
|
-
version: "0.3.
|
|
11
|
+
version: "0.3.1",
|
|
12
12
|
type: "action",
|
|
13
13
|
methods: {
|
|
14
14
|
...common.methods,
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "salesforce_rest_api-create-record",
|
|
9
9
|
name: "Create Record",
|
|
10
10
|
description: "Create a record of a given object. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm)",
|
|
11
|
-
version: "0.3.
|
|
11
|
+
version: "0.3.1",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
salesforce,
|
|
@@ -15,7 +15,7 @@ export default {
|
|
|
15
15
|
key: "salesforce_rest_api-update-account",
|
|
16
16
|
name: "Update Account",
|
|
17
17
|
description: `Updates a Salesforce account. [See the documentation](${docsLink})`,
|
|
18
|
-
version: "0.3.
|
|
18
|
+
version: "0.3.1",
|
|
19
19
|
type: "action",
|
|
20
20
|
methods: {
|
|
21
21
|
...common.methods,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
key: "salesforce_rest_api-update-contact",
|
|
17
17
|
name: "Update Contact",
|
|
18
18
|
description: `Updates a contact. [See the documentation](${docsLink})`,
|
|
19
|
-
version: "0.3.
|
|
19
|
+
version: "0.3.1",
|
|
20
20
|
type: "action",
|
|
21
21
|
methods: {
|
|
22
22
|
...common.methods,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
key: "salesforce_rest_api-update-opportunity",
|
|
17
17
|
name: "Update Opportunity",
|
|
18
18
|
description: `Updates an opportunity. [See the documentation](${docsLink})`,
|
|
19
|
-
version: "0.3.
|
|
19
|
+
version: "0.3.1",
|
|
20
20
|
type: "action",
|
|
21
21
|
methods: {
|
|
22
22
|
...common.methods,
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "salesforce_rest_api-update-record",
|
|
9
9
|
name: "Update Record",
|
|
10
10
|
description: "Update fields of a record. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_update_fields.htm)",
|
|
11
|
-
version: "0.3.
|
|
11
|
+
version: "0.3.1",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
salesforce,
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertFieldsToProps, getAdditionalFields,
|
|
3
|
+
} from "../../common/props-utils.mjs";
|
|
4
|
+
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
5
|
+
import { additionalFields } from "../common/base-create-update.mjs";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
key: "salesforce_rest_api-upsert-record",
|
|
9
|
+
name: "Upsert Record",
|
|
10
|
+
description: "Create or update a record of a given object. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm)",
|
|
11
|
+
version: "0.0.2",
|
|
12
|
+
type: "action",
|
|
13
|
+
props: {
|
|
14
|
+
salesforce,
|
|
15
|
+
objectType: {
|
|
16
|
+
propDefinition: [
|
|
17
|
+
salesforce,
|
|
18
|
+
"objectType",
|
|
19
|
+
],
|
|
20
|
+
description: "The type of object to create a record of",
|
|
21
|
+
reloadProps: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
getAdditionalFields,
|
|
26
|
+
convertFieldsToProps,
|
|
27
|
+
async upsertRecord(sobjectName, {
|
|
28
|
+
externalIdFieldName, externalIdValue, ...args
|
|
29
|
+
}) {
|
|
30
|
+
const url = `${this.salesforce._sObjectTypeApiUrl(sobjectName)}/${externalIdFieldName}/${externalIdValue}`;
|
|
31
|
+
return this.salesforce._makeRequest({
|
|
32
|
+
url,
|
|
33
|
+
method: "PATCH",
|
|
34
|
+
...args,
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
async additionalProps() {
|
|
39
|
+
const { objectType } = this;
|
|
40
|
+
const fields = await this.salesforce.getFieldsForObjectType(objectType);
|
|
41
|
+
|
|
42
|
+
const requiredFields = fields.filter((field) => {
|
|
43
|
+
return field.createable && field.updateable && !field.nillable && !field.defaultedOnCreate;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const externalIdFieldOptions = fields.filter((field) => field.externalId).map(({
|
|
47
|
+
label, name,
|
|
48
|
+
}) => ({
|
|
49
|
+
label,
|
|
50
|
+
value: name,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const requiredFieldProps = this.convertFieldsToProps(requiredFields);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
docsInfo: {
|
|
57
|
+
type: "alert",
|
|
58
|
+
alertType: "info",
|
|
59
|
+
content: `[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_${objectType.toLowerCase()}.htm) for information on all available fields.`,
|
|
60
|
+
},
|
|
61
|
+
externalIdFieldName: {
|
|
62
|
+
type: "string",
|
|
63
|
+
label: "External ID Field",
|
|
64
|
+
description: "The field to use as the external ID to identify the record.",
|
|
65
|
+
options: externalIdFieldOptions,
|
|
66
|
+
},
|
|
67
|
+
docsInfoExtId: {
|
|
68
|
+
type: "alert",
|
|
69
|
+
alertType: "info",
|
|
70
|
+
content: "If you don't see any fields in the above list, you probably need to create one in Salesforce's Object Manager. Only a field marked as an external id field can be used to identify a record.",
|
|
71
|
+
},
|
|
72
|
+
externalIdValue: {
|
|
73
|
+
type: "string",
|
|
74
|
+
label: "External ID Value",
|
|
75
|
+
description: "The value of the external ID field selected above. If a record with this value exists, it will be updated, otherwise a new one will be created.",
|
|
76
|
+
},
|
|
77
|
+
updateOnly: {
|
|
78
|
+
type: "boolean",
|
|
79
|
+
label: "Update Only",
|
|
80
|
+
description: "If enabled, the action will only update an existing record, but not create one.",
|
|
81
|
+
optional: true,
|
|
82
|
+
},
|
|
83
|
+
...requiredFieldProps,
|
|
84
|
+
additionalFields,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
async run({ $ }) {
|
|
88
|
+
/* eslint-disable no-unused-vars */
|
|
89
|
+
const {
|
|
90
|
+
salesforce,
|
|
91
|
+
objectType,
|
|
92
|
+
getAdditionalFields: getData,
|
|
93
|
+
convertFieldsToProps,
|
|
94
|
+
docsInfo,
|
|
95
|
+
docsInfoExtId,
|
|
96
|
+
additionalFields,
|
|
97
|
+
externalIdFieldName,
|
|
98
|
+
externalIdValue,
|
|
99
|
+
updateOnly,
|
|
100
|
+
...data
|
|
101
|
+
} = this;
|
|
102
|
+
/* eslint-enable no-unused-vars */
|
|
103
|
+
const response = await this.upsertRecord(objectType, {
|
|
104
|
+
$,
|
|
105
|
+
externalIdFieldName,
|
|
106
|
+
externalIdValue,
|
|
107
|
+
params: {
|
|
108
|
+
updateOnly,
|
|
109
|
+
},
|
|
110
|
+
data: {
|
|
111
|
+
...data,
|
|
112
|
+
...getData(),
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
$.export("$summary", `Successfully ${response.created
|
|
116
|
+
? "created"
|
|
117
|
+
: "updated"} ${objectType} record (ID: ${response.id})`);
|
|
118
|
+
return response;
|
|
119
|
+
},
|
|
120
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
initialProps: {
|
|
3
|
+
LinkedEntityId: {
|
|
4
|
+
type: "string",
|
|
5
|
+
label: "Linked Entity ID",
|
|
6
|
+
description: "ID of the linked object. Can include Chatter users, groups, records (any that support Chatter feed tracking including custom objects), and Salesforce CRM Content libraries.",
|
|
7
|
+
optional: true,
|
|
8
|
+
},
|
|
9
|
+
ShareType: {
|
|
10
|
+
type: "string",
|
|
11
|
+
label: "Share Type",
|
|
12
|
+
description: "The permission granted to the user of the shared file in a library. This is determined by the permission the user already has in the library.",
|
|
13
|
+
optional: true,
|
|
14
|
+
default: "I",
|
|
15
|
+
options: [
|
|
16
|
+
{
|
|
17
|
+
label: "Viewer Permission",
|
|
18
|
+
value: "V",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Collaborator Permission",
|
|
22
|
+
value: "C",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Inferred Permission",
|
|
26
|
+
value: "I",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
Visibility: {
|
|
31
|
+
type: "string",
|
|
32
|
+
label: "Visibility",
|
|
33
|
+
description: "Specifies whether this file is available to all users, internal users, or shared users.",
|
|
34
|
+
optional: true,
|
|
35
|
+
options: [
|
|
36
|
+
{
|
|
37
|
+
label: "All Users",
|
|
38
|
+
value: "AllUsers",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "Internal Users",
|
|
42
|
+
value: "InternalUsers",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: "Shared Users",
|
|
46
|
+
value: "SharedUsers",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
initialProps: {
|
|
5
|
+
OwnerId: {
|
|
6
|
+
propDefinition: [
|
|
7
|
+
salesforce,
|
|
8
|
+
"recordId",
|
|
9
|
+
() => ({
|
|
10
|
+
objType: "User",
|
|
11
|
+
nameField: "Name",
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
label: "Owner ID",
|
|
15
|
+
description: "ID of the user who owns the note.",
|
|
16
|
+
},
|
|
17
|
+
Title: {
|
|
18
|
+
type: "string",
|
|
19
|
+
label: "Title",
|
|
20
|
+
description: "Title of the note.",
|
|
21
|
+
},
|
|
22
|
+
Content: {
|
|
23
|
+
type: "string",
|
|
24
|
+
label: "Content",
|
|
25
|
+
description: "The content or body of the note, which can include properly formatted HTML or plain text.",
|
|
26
|
+
},
|
|
27
|
+
IsReadOnly: {
|
|
28
|
+
type: "boolean",
|
|
29
|
+
label: "Read Only",
|
|
30
|
+
description: "Indicates whether the note is read only.",
|
|
31
|
+
optional: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|