@pipedream/salesforce_rest_api 1.2.1 → 1.3.1

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.
Files changed (64) hide show
  1. package/README.md +92 -0
  2. package/actions/add-contact-to-campaign/add-contact-to-campaign.mjs +25 -25
  3. package/actions/add-lead-to-campaign/add-lead-to-campaign.mjs +25 -24
  4. package/actions/common/base-create-update.mjs +108 -0
  5. package/actions/convert-soap-xml-to-json/convert-soap-xml-to-json.mjs +11 -3
  6. package/actions/create-account/create-account.mjs +33 -36
  7. package/actions/create-attachment/create-attachment.mjs +36 -50
  8. package/actions/create-campaign/create-campaign.mjs +41 -37
  9. package/actions/create-case/create-case.mjs +41 -37
  10. package/actions/create-casecomment/create-casecomment.mjs +26 -38
  11. package/actions/create-contact/create-contact.mjs +38 -35
  12. package/actions/create-event/create-event.mjs +57 -66
  13. package/actions/create-lead/create-lead.mjs +34 -42
  14. package/actions/create-note/create-note.mjs +24 -43
  15. package/actions/create-opportunity/create-opportunity.mjs +38 -47
  16. package/actions/create-record/create-record.mjs +49 -15
  17. package/actions/create-task/create-task.mjs +50 -42
  18. package/actions/create-user/create-user.mjs +33 -196
  19. package/actions/delete-opportunity/delete-opportunity.mjs +17 -13
  20. package/actions/delete-record/delete-record.mjs +18 -16
  21. package/actions/find-records/find-records.mjs +41 -26
  22. package/actions/insert-blob-data/insert-blob-data.mjs +3 -7
  23. package/actions/post-feed-to-chatter/post-feed-to-chatter.mjs +45 -20
  24. package/actions/search-string/search-string.mjs +22 -20
  25. package/actions/soql-search/soql-search.mjs +13 -8
  26. package/actions/sosl-search/sosl-search.mjs +19 -9
  27. package/actions/update-account/update-account.mjs +54 -41
  28. package/actions/update-contact/update-contact.mjs +59 -40
  29. package/actions/update-opportunity/update-opportunity.mjs +56 -54
  30. package/actions/update-record/update-record.mjs +67 -20
  31. package/common/all-sobjects.mjs +3812 -0
  32. package/common/constants-props.mjs +1539 -0
  33. package/common/props-async-options.mjs +154 -0
  34. package/common/props-utils.mjs +88 -31
  35. package/common/sobjects/account.mjs +349 -22
  36. package/common/sobjects/attachment.mjs +56 -17
  37. package/common/sobjects/campaign.mjs +125 -23
  38. package/common/sobjects/case.mjs +193 -13
  39. package/common/sobjects/caseComment.mjs +28 -4
  40. package/common/sobjects/contact.mjs +207 -43
  41. package/common/sobjects/event.mjs +218 -18
  42. package/common/sobjects/lead.mjs +245 -22
  43. package/common/sobjects/note.mjs +37 -14
  44. package/common/sobjects/opportunity.mjs +148 -22
  45. package/common/sobjects/task.mjs +240 -19
  46. package/common/sobjects/user.mjs +965 -0
  47. package/package.json +2 -2
  48. package/salesforce_rest_api.app.mjs +72 -249
  49. package/sources/common-webhook-methods.mjs +71 -0
  50. package/sources/common.mjs +85 -22
  51. package/sources/new-outbound-message/new-outbound-message.mjs +11 -3
  52. package/sources/new-record-instant/new-record-instant.mjs +95 -7
  53. package/sources/record-deleted-instant/record-deleted-instant.mjs +40 -5
  54. package/sources/record-updated-instant/record-updated-instant.mjs +137 -5
  55. package/actions/common/base.mjs +0 -18
  56. package/actions/find-create-record/find-create-record.mjs +0 -89
  57. package/actions/get-sobject-fields-values/get-sobject-fields-values.mjs +0 -57
  58. package/common/utils.mjs +0 -51
  59. package/sources/common-instant.mjs +0 -146
  60. package/sources/new-record/new-record.mjs +0 -91
  61. package/sources/record-deleted/record-deleted.mjs +0 -51
  62. package/sources/record-updated/record-updated.mjs +0 -94
  63. package/sources/updated-field-on-record/updated-field-on-record.mjs +0 -161
  64. package/sources/updated-field-on-record-instant/updated-field-on-record-instant.mjs +0 -76
@@ -1,63 +1,54 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import opportunity from "../../common/sobjects/opportunity.mjs";
3
- import {
4
- pickBy, pick,
5
- } from "lodash-es";
6
- import { toSingleLineString } from "../../common/utils.mjs";
7
3
 
8
- const { salesforce } = common.props;
4
+ export const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm";
9
5
 
10
6
  export default {
11
7
  ...common,
12
8
  key: "salesforce_rest_api-create-opportunity",
13
9
  name: "Create Opportunity",
14
- description: toSingleLineString(`
15
- Creates an opportunity, which represents an opportunity, which is a sale or pending deal.
16
- See [Opportunity SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm)
17
- and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
18
- `),
19
- version: "0.2.7",
10
+ description: `Creates an opportunity. [See the documentation](${docsLink})`,
11
+ version: "0.3.0",
20
12
  type: "action",
21
- props: {
22
- salesforce,
23
- CloseDate: {
24
- type: "string",
25
- label: "Close date",
26
- description: "Date when the opportunity is expected to close.",
13
+ methods: {
14
+ ...common.methods,
15
+ getObjectType() {
16
+ return "Opportunity";
27
17
  },
28
- Name: {
29
- type: "string",
30
- label: "Name",
31
- description: "A name for this opportunity. Limit: 120 characters.",
18
+ getAdvancedProps() {
19
+ return opportunity.extraProps;
32
20
  },
33
- StageName: {
34
- type: "string",
35
- label: "StageName",
36
- description: "Current stage of this record. The StageName field controls several other fields on an opportunity. Each of the fields can be directly set or implied by changing the StageName field. In addition, the StageName field is a picklist, so it has additional members in the returned describeSObjectResult to indicate how it affects the other fields. To obtain the stage name values in the picklist, query the OpportunityStage object. If the StageName is updated, then the ForecastCategoryName, IsClosed, IsWon, and Probability are automatically updated based on the stage-category mapping.",
37
- },
38
- selector: {
39
- propDefinition: [
40
- salesforce,
41
- "fieldSelector",
42
- ],
43
- description: `${salesforce.propDefinitions.fieldSelector.description} Opportunity`,
44
- options: () => Object.keys(opportunity),
45
- reloadProps: true,
46
- },
47
- },
48
- additionalProps() {
49
- return this.additionalProps(this.selector, opportunity);
50
21
  },
22
+ props: getProps({
23
+ objType: opportunity,
24
+ docsLink,
25
+ showDateInfo: true,
26
+ }),
51
27
  async run({ $ }) {
52
- const data = pickBy(pick(this, [
53
- "CloseDate",
54
- "Name",
55
- "StageName",
56
- ...this.selector,
57
- ]));
58
- const response = await this.salesforce.createOpportunity({
28
+ /* eslint-disable no-unused-vars */
29
+ const {
30
+ salesforce,
31
+ getAdvancedProps,
32
+ getObjectType,
33
+ getAdditionalFields,
34
+ formatDateTimeProps,
35
+ useAdvancedProps,
36
+ docsInfo,
37
+ dateInfo,
38
+ additionalFields,
39
+ CloseDate,
40
+ ...data
41
+ } = this;
42
+ /* eslint-enable no-unused-vars */
43
+ const response = await salesforce.createRecord("Opportunity", {
59
44
  $,
60
- data,
45
+ data: {
46
+ ...data,
47
+ ...formatDateTimeProps({
48
+ CloseDate,
49
+ }),
50
+ ...getAdditionalFields(),
51
+ },
61
52
  });
62
53
  $.export("$summary", `Successfully created opportunity "${this.Name}"`);
63
54
  return response;
@@ -1,14 +1,14 @@
1
+ import {
2
+ convertFieldsToProps, getAdditionalFields,
3
+ } from "../../common/props-utils.mjs";
1
4
  import salesforce from "../../salesforce_rest_api.app.mjs";
2
- import { toSingleLineString } from "../../common/utils.mjs";
5
+ import { additionalFields } from "../common/base-create-update.mjs";
3
6
 
4
7
  export default {
5
8
  key: "salesforce_rest_api-create-record",
6
9
  name: "Create Record",
7
- description: toSingleLineString(`
8
- Create new records of a given resource.
9
- See [docs](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm)
10
- `),
11
- version: "0.2.7",
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.0",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
@@ -17,20 +17,54 @@ export default {
17
17
  salesforce,
18
18
  "objectType",
19
19
  ],
20
- description: "SObject Type for this record",
21
- },
22
- sobject: {
23
- type: "object",
24
- label: "SObject fields and values",
25
- description: "Data of the SObject record to create",
20
+ description: "The type of object to create a record of",
21
+ reloadProps: true,
26
22
  },
27
23
  },
24
+ methods: {
25
+ getAdditionalFields,
26
+ convertFieldsToProps,
27
+ },
28
+ async additionalProps() {
29
+ const { objectType } = this;
30
+ const fields = await this.salesforce.getFieldsForObjectType(objectType);
31
+
32
+ const requiredFields = fields.filter((field) => {
33
+ return field.createable && !field.nillable && !field.defaultedOnCreate;
34
+ });
35
+
36
+ const requiredFieldProps = this.convertFieldsToProps(requiredFields);
37
+
38
+ return {
39
+ docsInfo: {
40
+ type: "alert",
41
+ alertType: "info",
42
+ 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.`,
43
+ },
44
+ ...requiredFieldProps,
45
+ additionalFields,
46
+ };
47
+ },
28
48
  async run({ $ }) {
29
- const response = await this.salesforce.createRecord(this.objectType, {
49
+ /* eslint-disable no-unused-vars */
50
+ const {
51
+ salesforce,
52
+ objectType,
53
+ getAdditionalFields: getData,
54
+ convertFieldsToProps,
55
+ docsInfo,
56
+ additionalFields,
57
+ ...data
58
+ } = this;
59
+ /* eslint-enable no-unused-vars */
60
+ const response = await salesforce.createRecord(objectType, {
30
61
  $,
31
- data: this.sobject,
62
+ data: {
63
+ ...data,
64
+ ...getData(),
65
+ },
32
66
  });
33
- $.export("$summary", `Created record "${this.objectType}"`);
67
+ $.export("$summary", `Successfully created ${objectType} record (ID: ${response.id})`);
34
68
  return response;
35
69
  },
36
70
  };
@@ -1,59 +1,67 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import task from "../../common/sobjects/task.mjs";
3
- import {
4
- pickBy, pick,
5
- } from "lodash-es";
6
- import { toSingleLineString } from "../../common/utils.mjs";
7
3
 
8
- const { salesforce } = common.props;
4
+ const docsLink =
5
+ "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_task.htm";
9
6
 
10
7
  export default {
11
8
  ...common,
12
9
  key: "salesforce_rest_api-create-task",
13
10
  name: "Create Task",
14
- description: toSingleLineString(`
15
- Creates a task, which represents a business activity such as making a phone call or other to-do items.
16
- See [Task SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_task.htm)
17
- and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
18
- `),
19
- version: "0.3.7",
11
+ description: `Creates a task. [See the documentation](${docsLink})`,
12
+ version: "0.4.0",
20
13
  type: "action",
21
- props: {
22
- salesforce,
23
- Priority: {
24
- type: "string",
25
- label: "Priority",
26
- description: "Required. Indicates the importance or urgency of a task, such as high or low.",
14
+ methods: {
15
+ ...common.methods,
16
+ getObjectType() {
17
+ return "Task";
27
18
  },
28
- Status: {
29
- type: "string",
30
- label: "Status",
31
- description: "Required. The status of the task, such as In Progress or Completed. Each predefined Status field implies a value for the IsClosed flag. To obtain picklist values, query the TaskStatus object. Note This field can't be updated for recurring tasks (IsRecurrence is true).",
19
+ getAdvancedProps() {
20
+ return task.extraProps;
32
21
  },
33
- selector: {
34
- propDefinition: [
35
- salesforce,
36
- "fieldSelector",
37
- ],
38
- description: `${salesforce.propDefinitions.fieldSelector.description} Task`,
39
- options: () => Object.keys(task),
40
- reloadProps: true,
41
- },
42
- },
43
- additionalProps() {
44
- return this.additionalProps(this.selector, task);
45
22
  },
23
+ props: getProps({
24
+ objType: task,
25
+ docsLink,
26
+ showDateInfo: true,
27
+ }),
46
28
  async run({ $ }) {
47
- const data = pickBy(pick(this, [
48
- "Priority",
49
- "Status",
50
- ...this.selector,
51
- ]));
52
- const response = await this.salesforce.createTask({
29
+ /* eslint-disable no-unused-vars */
30
+ const {
31
+ salesforce,
32
+ getAdvancedProps,
33
+ getObjectType,
34
+ getAdditionalFields,
35
+ formatDateTimeProps,
36
+ useAdvancedProps,
37
+ docsInfo,
38
+ dateInfo,
39
+ additionalFields,
40
+ ActivityDate,
41
+ RecurrenceEndDateOnly,
42
+ RecurrenceStartDateOnly,
43
+ ReminderDateTime,
44
+ RecurrenceDayOfWeekMask,
45
+ ...data
46
+ } = this;
47
+ /* eslint-enable no-unused-vars */
48
+ const response = await salesforce.createRecord("Task", {
53
49
  $,
54
- data,
50
+ data: {
51
+ ...data,
52
+ ...formatDateTimeProps({
53
+ ActivityDate,
54
+ RecurrenceEndDateOnly,
55
+ RecurrenceStartDateOnly,
56
+ ReminderDateTime,
57
+ }),
58
+ RecurrenceDayOfWeekMask: RecurrenceDayOfWeekMask?.reduce?.((acc, val) => acc + val, 0),
59
+ ...getAdditionalFields(),
60
+ },
55
61
  });
56
- $.export("$summary", "Successfully created task");
62
+ $.export("$summary", `Succcessfully created task${this.Subject
63
+ ? ` "${this.Subject}"`
64
+ : ""}`);
57
65
  return response;
58
66
  },
59
67
  };
@@ -1,215 +1,52 @@
1
- import common from "../common/base.mjs";
2
- import utils from "../../common/props-utils.mjs";
3
- import { toSingleLineString } from "../../common/utils.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
+ import user from "../../common/sobjects/user.mjs";
4
3
 
5
- const { salesforce } = common.props;
4
+ const docsLink =
5
+ "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_user.htm";
6
6
 
7
7
  export default {
8
8
  ...common,
9
9
  key: "salesforce_rest_api-create-user",
10
10
  name: "Create User",
11
- description: toSingleLineString(`
12
- Creates a Salesforce user.
13
- See [User SObject](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_user.htm)
14
- and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm)
15
- `),
16
- version: "0.0.1",
11
+ description: `Creates a Salesforce user. [See the documentation](${docsLink})`,
12
+ version: "0.1.0",
17
13
  type: "action",
18
- props: {
19
- salesforce,
20
- alias: {
21
- type: "string",
22
- label: "Alias",
23
- description: "Alias of the user. The alias can contain only underscores and alphanumeric characters. It must be unique in your org, not include spaces, not end with a hyphen, and not contain two consecutive hyphens.",
24
- },
25
- email: {
26
- type: "string",
27
- label: "Email",
28
- description: "The email address of the user.",
29
- },
30
- emailEncodingKey: {
31
- type: "string",
32
- label: "Email Encoding Key",
33
- description: "The key used to encode the user's email.",
34
- options: [
35
- "ISO-8859-1",
36
- "UTF-8",
37
- "Shift_JIS",
38
- "EUC-JP",
39
- "ISO-2022-JP",
40
- ],
41
- default: "UTF-8",
42
- },
43
- languageLocaleKey: {
44
- type: "string",
45
- label: "Language Locale Key",
46
- description: "The user's language locale key.",
47
- async options() {
48
- const fields = await this.salesforce.getFieldsForObjectType("User");
49
- const { picklistValues } = fields.find(({ name }) => name === "LanguageLocaleKey");
50
- return picklistValues.map(({
51
- value, label,
52
- }) => ({
53
- label,
54
- value,
55
- }));
56
- },
57
- },
58
- firstName: {
59
- type: "string",
60
- label: "First Name",
61
- description: "The user's first name.",
62
- optional: true,
63
- },
64
- lastName: {
65
- type: "string",
66
- label: "Last Name",
67
- description: "The user's last name.",
68
- },
69
- localeSidKey: {
70
- type: "string",
71
- label: "Locale Sid Key",
72
- description: "The user's locale sid key.",
73
- async options() {
74
- const fields = await this.salesforce.getFieldsForObjectType("User");
75
- const { picklistValues } = fields.find(({ name }) => name === "LocaleSidKey");
76
- return picklistValues.map(({
77
- value, label,
78
- }) => ({
79
- label,
80
- value,
81
- }));
82
- },
83
- },
84
- profileId: {
85
- type: "string",
86
- label: "Profile ID",
87
- description: "The ID of the user's profile.",
88
- async options() {
89
- const { records } = await this.salesforce.query({
90
- query: "SELECT Id, Name FROM Profile",
91
- });
92
- return records.map(({
93
- Id: value, Name: label,
94
- }) => ({
95
- label,
96
- value,
97
- }));
98
- },
99
- },
100
- timeZoneSidKey: {
101
- type: "string",
102
- label: "Time Zone Sid Key",
103
- description: "The user's time zone sid key.",
104
- async options() {
105
- const fields = await this.salesforce.getFieldsForObjectType("User");
106
- const { picklistValues } = fields.find(({ name }) => name === "TimeZoneSidKey");
107
- return picklistValues.map(({
108
- value, label,
109
- }) => ({
110
- label,
111
- value,
112
- }));
113
- },
114
- },
115
- userName: {
116
- type: "string",
117
- label: "User Name",
118
- description: "The user's username. It should be in email format. Eg. `john@acme.com`.",
119
- },
120
- title: {
121
- type: "string",
122
- label: "Title",
123
- description: "The user's title.",
124
- optional: true,
125
- },
126
- department: {
127
- type: "string",
128
- label: "Department",
129
- description: "The department the user belongs to.",
130
- optional: true,
131
- },
132
- division: {
133
- type: "string",
134
- label: "Division",
135
- description: "The division the user belongs to.",
136
- optional: true,
137
- },
138
- phone: {
139
- type: "string",
140
- label: "Phone",
141
- description: "The user's phone number.",
142
- optional: true,
143
- },
144
- mobilePhone: {
145
- type: "string",
146
- label: "Mobile Phone",
147
- description: "The user's mobile phone number.",
148
- optional: true,
149
- },
150
- street: {
151
- type: "string",
152
- label: "Street",
153
- description: "The user's street address.",
154
- optional: true,
155
- },
156
- city: {
157
- type: "string",
158
- label: "City",
159
- description: "The user's city.",
160
- optional: true,
161
- },
162
- state: {
163
- type: "string",
164
- label: "State",
165
- description: "The user's state.",
166
- optional: true,
167
- },
168
- postalCode: {
169
- type: "string",
170
- label: "Postal Code",
171
- description: "The user's postal code.",
172
- optional: true,
173
- },
174
- country: {
175
- type: "string",
176
- label: "Country",
177
- description: "The user's country.",
178
- optional: true,
179
- },
180
- userRoleId: {
181
- type: "string",
182
- label: "User Role ID",
183
- description: "The ID of the user's role.",
184
- optional: true,
185
- },
186
- isActive: {
187
- type: "boolean",
188
- label: "Is Active",
189
- description: "Whether the user is active.",
190
- optional: true,
191
- },
192
- },
193
14
  methods: {
194
- createUser(args = {}) {
195
- return this.salesforce._makeRequest({
196
- method: "POST",
197
- url: this.salesforce._sObjectTypeApiUrl("User"),
198
- ...args,
199
- });
15
+ ...common.methods,
16
+ getObjectType() {
17
+ return "User";
18
+ },
19
+ getAdvancedProps() {
20
+ return user.extraProps;
200
21
  },
201
22
  },
23
+ props: getProps({
24
+ objType: user,
25
+ docsLink,
26
+ }),
202
27
  async run({ $ }) {
28
+ /* eslint-disable no-unused-vars */
203
29
  const {
204
- createUser,
30
+ salesforce,
31
+ getAdvancedProps,
32
+ getObjectType,
33
+ getAdditionalFields,
34
+ formatDateTimeProps,
35
+ useAdvancedProps,
36
+ docsInfo,
37
+ dateInfo,
38
+ additionalFields,
205
39
  ...data
206
40
  } = this;
207
-
208
- const response = await createUser({
41
+ /* eslint-enable no-unused-vars */
42
+ const response = await salesforce.createRecord("User", {
209
43
  $,
210
- data: utils.keysToCapitalCase(data),
44
+ data: {
45
+ ...data,
46
+ ...getAdditionalFields(),
47
+ },
211
48
  });
212
- $.export("$summary", `Successfully created user with ID \`${response.id}\``);
49
+ $.export("$summary", `Successfully created user (ID: ${response.id})`);
213
50
  return response;
214
51
  },
215
52
  };
@@ -1,30 +1,34 @@
1
1
  import salesforce from "../../salesforce_rest_api.app.mjs";
2
- import { toSingleLineString } from "../../common/utils.mjs";
3
2
 
4
3
  export default {
5
4
  key: "salesforce_rest_api-delete-opportunity",
6
5
  name: "Delete Opportunity",
7
- description: toSingleLineString(`
8
- Deletes an opportunity.
9
- See [Opportunity SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm)
10
- and [Delete Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_delete_record.htm)
11
- `),
12
- version: "0.2.7",
6
+ description: "Deletes an opportunity. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_delete_record.htm)",
7
+ version: "0.3.0",
13
8
  type: "action",
14
9
  props: {
15
10
  salesforce,
16
- OpportunityId: {
17
- type: "string",
11
+ recordId: {
12
+ propDefinition: [
13
+ salesforce,
14
+ "recordId",
15
+ () => ({
16
+ objType: "Opportunity",
17
+ nameField: "Name",
18
+ }),
19
+ ],
18
20
  label: "Opportunity ID",
19
- description: "ID of the Opportunity to delete",
21
+ description: "ID of the opportunity to delete.",
20
22
  },
21
23
  },
22
24
  async run({ $ }) {
23
- const response = await this.salesforce.deleteOpportunity({
25
+ const { recordId } = this;
26
+ const response = await this.salesforce.deleteRecord({
27
+ sobjectType: "Opportunity",
24
28
  $,
25
- id: this.OpportunityId,
29
+ recordId,
26
30
  });
27
- $.export("$summary", "Successfully deleted opportunity");
31
+ $.export("$summary", `Successfully deleted opportunity (ID: ${recordId})`);
28
32
  return response;
29
33
  },
30
34
  };
@@ -1,42 +1,44 @@
1
- import salesForceRestApi from "../../salesforce_rest_api.app.mjs";
1
+ import salesforce from "../../salesforce_rest_api.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "salesforce_rest_api-delete-record",
5
- name: "Delete a Record in an Object",
5
+ name: "Delete Record",
6
6
  description:
7
- "Deletes an existing record in an object. [API Doc](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm)",
8
- version: "0.1.5",
7
+ "Deletes an existing record in an object. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve_delete.htm)",
8
+ version: "0.2.0",
9
9
  type: "action",
10
10
  props: {
11
- salesForceRestApi,
11
+ salesforce,
12
12
  sobjectType: {
13
13
  propDefinition: [
14
- salesForceRestApi,
14
+ salesforce,
15
15
  "objectType",
16
16
  ],
17
+ description: "The type of object to delete a record of.",
17
18
  },
18
- sobjectId: {
19
+ recordId: {
19
20
  propDefinition: [
20
- salesForceRestApi,
21
- "sobjectId",
21
+ salesforce,
22
+ "recordId",
22
23
  (c) => ({
23
- objectType: c.sobjectType,
24
+ objType: c.sobjectType,
24
25
  }),
25
26
  ],
26
27
  description:
27
- "ID of the Salesforce standard object to get field values from.",
28
+ "The record to delete.",
28
29
  },
29
30
  },
30
31
  async run({ $ }) {
31
32
  const {
32
33
  sobjectType,
33
- sobjectId,
34
+ recordId,
34
35
  } = this;
35
- const response = await this.salesForceRestApi.deleteObject(
36
+ const response = await this.salesforce.deleteRecord({
37
+ $,
36
38
  sobjectType,
37
- sobjectId,
38
- );
39
- response && $.export("$summary", `Successfully deleted record with ID ${sobjectId}`);
39
+ recordId,
40
+ });
41
+ $.export("$summary", `Successfully deleted record (ID: ${recordId})`);
40
42
  return response;
41
43
  },
42
44
  };