@pipedream/salesforce_rest_api 1.2.0 → 1.3.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.
Files changed (65) 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 +77 -254
  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 +77 -6
  53. package/sources/record-deleted-instant/record-deleted-instant.mjs +40 -5
  54. package/sources/record-updated-instant/record-updated-instant.mjs +168 -0
  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/object-updated/object-updated.mjs +0 -94
  62. package/sources/object-updated-instant/object-updated-instant.mjs +0 -36
  63. package/sources/record-deleted/record-deleted.mjs +0 -51
  64. package/sources/updated-field-on-record/updated-field-on-record.mjs +0 -161
  65. package/sources/updated-field-on-record-instant/updated-field-on-record-instant.mjs +0 -76
@@ -1,52 +1,67 @@
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-find-records",
5
- name: "Get Object Records",
5
+ name: "Find Records",
6
6
  description:
7
- "Retrieves all records in an object or a record in an object by the given ID or criteria. [API Doc](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)",
8
- version: "0.1.5",
7
+ "Retrieves selected fields for some or all records of a selected object. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.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 obtain records of.",
17
18
  },
18
- ids: {
19
+ fieldsToObtain: {
19
20
  propDefinition: [
20
- salesForceRestApi,
21
- "sobjectId",
21
+ salesforce,
22
+ "fieldsToObtain",
22
23
  (c) => ({
23
- objectType: c.sobjectType,
24
+ objType: c.sobjectType,
24
25
  }),
25
26
  ],
26
- type: "string[]",
27
27
  },
28
- fields: {
28
+ recordIds: {
29
+ propDefinition: [
30
+ salesforce,
31
+ "recordId",
32
+ (c) => ({
33
+ objType: c.sobjectType,
34
+ }),
35
+ ],
36
+ label: "Record ID(s)",
29
37
  type: "string[]",
30
- label: "Fields to get values from",
38
+ optional: true,
31
39
  description:
32
- "list of the Salesforce standard object's fields to get values from.",
40
+ "The record(s) to retrieve. If not specified, all records will be retrieved.",
33
41
  },
34
42
  },
35
43
  async run({ $ }) {
36
- const {
44
+ let {
37
45
  sobjectType,
38
- fields,
39
- ids,
46
+ recordIds,
47
+ fieldsToObtain,
40
48
  } = this;
41
- const response = await this.salesForceRestApi.getRecords(
42
- sobjectType, {
43
- fields: Array.isArray(fields) && fields.join(",") || fields,
44
- ids: Array.isArray(ids) && ids.join(",") || ids,
45
- },
46
- );
47
- if (response) {
48
- $.export("$summary", "Record found successfully");
49
+
50
+ if (typeof recordIds === "string") recordIds = recordIds.split(",");
51
+ if (typeof fieldsToObtain === "string") fieldsToObtain = fieldsToObtain.split(",");
52
+
53
+ let query = `SELECT ${fieldsToObtain.join(", ")} FROM ${sobjectType}`;
54
+
55
+ if (recordIds?.length) {
56
+ query += ` WHERE Id IN ('${recordIds.join("','")}')`;
49
57
  }
50
- return response;
58
+
59
+ const { records } = await this.salesforce.query({
60
+ $,
61
+ query,
62
+ });
63
+
64
+ $.export("$summary", `Sucessfully retrieved ${records.length} records`);
65
+ return records;
51
66
  },
52
67
  };
@@ -1,14 +1,10 @@
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-insert-blob-data",
6
5
  name: "Insert Blob Data",
7
- description: toSingleLineString(`
8
- Inserts blob data in Salesforce standard objects.
9
- See [docs](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm)
10
- `),
11
- version: "0.2.7",
6
+ description: "Inserts blob data in Salesforce standard objects. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm)",
7
+ version: "0.2.8",
12
8
  type: "action",
13
9
  props: {
14
10
  salesforce,
@@ -71,7 +67,7 @@ export default {
71
67
  headers,
72
68
  data,
73
69
  });
74
- $.export("$summary", `Inserted Blob data to ${this.sobjectName}`);
70
+ $.export("$summary", `Successfully inserted blob data in ${this.sobjectName}`);
75
71
  return response;
76
72
  },
77
73
  };
@@ -1,39 +1,64 @@
1
- import salesForceRestApi from "../../salesforce_rest_api.app.mjs";
2
- import { toSingleLineString } from "../../common/utils.mjs";
1
+ import salesforce from "../../salesforce_rest_api.app.mjs";
3
2
 
4
3
  export default {
5
4
  key: "salesforce_rest_api-post-feed-to-chatter",
6
5
  name: "Post a Message to Chatter Feed",
7
- description: toSingleLineString(`
8
- Posts a message to the Chatter Feed.
9
- [See doc](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/quickreference_post_feed_item.htm)
10
- `),
11
- version: "0.0.6",
6
+ description:
7
+ "Post a feed item in Chatter. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/quickreference_post_feed_item.htm)",
8
+ version: "0.1.0",
12
9
  type: "action",
13
10
  props: {
14
- salesForceRestApi,
15
- text: {
16
- label: "Text body",
17
- description: "Text body.",
18
- type: "string",
11
+ salesforce,
12
+ sobjectType: {
13
+ propDefinition: [
14
+ salesforce,
15
+ "objectType",
16
+ ],
17
+ description: "The type of object to select a record from.",
19
18
  },
20
19
  subjectId: {
21
- label: "Subject ID",
22
- description: "Specify the user, group, or record that will parent the feed item.",
23
- type: "string",
20
+ propDefinition: [
21
+ salesforce,
22
+ "recordId",
23
+ (c) => ({
24
+ objType: c.sobjectType,
25
+ }),
26
+ ],
27
+ description: "The record that will parent the feed item.",
28
+ },
29
+ messageSegments: {
30
+ label: "Message segments",
31
+ description:
32
+ "Each message segment can be a text string, which will be treated as a segment of `type: Text`, or a [message segment object](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_requests_message_body_input.htm) such as `{ \"type\": \"Mention\", \"username\": \"john\" }`",
33
+ type: "string[]",
24
34
  },
25
35
  },
26
36
  async run({ $ }) {
27
- const params = {
28
- text: this.text,
37
+ const data = {
29
38
  subjectId: this.subjectId,
30
39
  feedElementType: "FeedItem",
40
+ body: {
41
+ messageSegments: this.messageSegments.map((segment) => {
42
+ if (typeof segment === "string") {
43
+ try {
44
+ return JSON.parse(segment);
45
+ } catch (err) {
46
+ return {
47
+ type: "Text",
48
+ text: segment,
49
+ };
50
+ }
51
+ }
52
+
53
+ return segment;
54
+ }),
55
+ },
31
56
  };
32
- const response = await this.salesForceRestApi.postFeed({
57
+ const response = await this.salesforce.postFeed({
33
58
  $,
34
- params,
59
+ data,
35
60
  });
36
- response && $.export("$summary", "Successfully added message to chatter feed");
61
+ response && $.export("$summary", "Successfully posted feed item");
37
62
  return response;
38
63
  },
39
64
  };
@@ -1,19 +1,25 @@
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-search-string",
5
5
  name: "Search Object Records",
6
6
  description:
7
- "Searches for records in an object using a parameterized search. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_search_parameterized.htm)",
8
- version: "0.0.1",
7
+ "Searches for records in an object using a parameterized search. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_search_parameterized_get.htm)",
8
+ version: "0.0.2",
9
9
  type: "action",
10
10
  props: {
11
- salesForceRestApi,
11
+ salesforce,
12
+ infoBox: {
13
+ type: "alert",
14
+ alertType: "info",
15
+ content: "If you need a more flexible search, consider using the **SOQL Search** or **SOSL Search** actions instead.",
16
+ },
12
17
  sobjectType: {
13
18
  propDefinition: [
14
- salesForceRestApi,
19
+ salesforce,
15
20
  "objectType",
16
21
  ],
22
+ description: "The type of object to search for records.",
17
23
  },
18
24
  searchTerm: {
19
25
  type: "string",
@@ -22,9 +28,9 @@ export default {
22
28
  },
23
29
  fields: {
24
30
  type: "string[]",
25
- label: "Fields to get values from",
31
+ label: "Fields",
26
32
  description:
27
- "List of the Salesforce object's fields to get values from.",
33
+ "List of the Salesforce object's fields to get values from, such as `Id` or `Name`.",
28
34
  },
29
35
  },
30
36
  async run({ $ }) {
@@ -33,21 +39,17 @@ export default {
33
39
  searchTerm,
34
40
  fields,
35
41
  } = this;
36
- try {
37
- const response = await this.salesForceRestApi.parameterizedSearch({
42
+
43
+ const response = await this.salesforce.parameterizedSearch({
44
+ $,
45
+ params: {
38
46
  q: searchTerm,
39
47
  sobject: sobjectType,
40
48
  fields: fields.join(","),
41
- });
42
- const resultsFound = response.searchRecords.length;
43
- $.export("$summary", "Search completed successfully");
44
- $.export("results_found", resultsFound);
45
- return response;
46
- } catch (error) {
47
- console.error(error);
48
- $.export("$summary", "Search failed");
49
- $.export("results_found", 0);
50
- throw new Error(`Search failed: ${error.message}`);
51
- }
49
+ },
50
+ });
51
+ const resultsFound = response.searchRecords.length;
52
+ $.export("$summary", `Sucessfully found ${resultsFound} results`);
53
+ return response;
52
54
  },
53
55
  };
@@ -1,21 +1,26 @@
1
- import { toSingleLineString } from "../../common/utils.mjs";
2
1
  import salesforce from "../../salesforce_rest_api.app.mjs";
2
+ import { docsInfo } from "../sosl-search/sosl-search.mjs";
3
+
4
+ const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_examples.htm";
3
5
 
4
6
  export default {
5
7
  key: "salesforce_rest_api-soql-search",
6
- name: "SOQL Search",
7
- description: toSingleLineString(`
8
- Executes a SOQL query.
9
- See [docs](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm)
10
- `),
11
- version: "0.2.8",
8
+ name: "SOQL Query (Object Query)",
9
+ description: `Executes a [Salesforce Object Query Language (SOQL)](${docsLink}) query-based, SQL-like search.`,
10
+ version: "0.2.9",
12
11
  type: "action",
13
12
  props: {
14
13
  salesforce,
14
+ docsInfo,
15
+ exampleInfo: {
16
+ type: "alert",
17
+ alertType: "info",
18
+ content: "Example query: `SELECT Id, Name, BillingCity FROM Account`",
19
+ },
15
20
  query: {
16
21
  type: "string",
17
22
  label: "SOQL Query",
18
- description: "A SOQL search query",
23
+ description: `A SOQL search query. [See the documentation](${docsLink}) for examples and more information.`,
19
24
  },
20
25
  },
21
26
  async run({ $ }) {
@@ -1,21 +1,31 @@
1
1
  import salesforce from "../../salesforce_rest_api.app.mjs";
2
- import { toSingleLineString } from "../../common/utils.mjs";
2
+
3
+ const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_examples.htm";
4
+
5
+ export const docsInfo = {
6
+ type: "alert",
7
+ alertType: "info",
8
+ content: "You can find helpful information on SOQL and SOSL in [the Salesforce documentation](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_sosl_intro.htm).",
9
+ };
3
10
 
4
11
  export default {
5
12
  key: "salesforce_rest_api-sosl-search",
6
- name: "SOSL Search",
7
- description: toSingleLineString(`
8
- Executes the specified SOSL search.
9
- See [docs](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl.htm)
10
- `),
11
- version: "0.2.7",
13
+ name: "SOSL Search (Object Search)",
14
+ description: `Executes a [Salesforce Object Search Language (SOSL)](${docsLink}) text-based search query.`,
15
+ version: "0.2.8",
12
16
  type: "action",
13
17
  props: {
14
18
  salesforce,
19
+ docsInfo,
20
+ exampleInfo: {
21
+ type: "alert",
22
+ alertType: "info",
23
+ content: "Example search: `FIND {Joe Smith} IN Name Fields RETURNING lead(name, phone)`",
24
+ },
15
25
  search: {
16
26
  type: "string",
17
27
  label: "SOSL Query",
18
- description: "A SOSL search query",
28
+ description: `A SOSL search query. [See the documentation](${docsLink}) for examples and more information.`,
19
29
  },
20
30
  },
21
31
  async run({ $ }) {
@@ -23,7 +33,7 @@ export default {
23
33
  $,
24
34
  search: this.search,
25
35
  });
26
- $.export("$summary", "Successfully returned ${response.length} results for SOSL search");
36
+ $.export("$summary", `Successfully returned ${response.searchRecords?.length} results for SOSL search`);
27
37
  return response;
28
38
  },
29
39
  };
@@ -1,62 +1,75 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import account from "../../common/sobjects/account.mjs";
3
- import {
4
- pickBy, pick,
5
- } from "lodash-es";
6
- import { toSingleLineString } from "../../common/utils.mjs";
3
+ import { docsLink } from "../create-account/create-account.mjs";
7
4
 
8
- const { salesforce } = common.props;
5
+ const {
6
+ salesforce, ...props
7
+ } = getProps({
8
+ createOrUpdate: "update",
9
+ objType: account,
10
+ docsLink,
11
+ });
9
12
 
10
13
  export default {
11
14
  ...common,
12
15
  key: "salesforce_rest_api-update-account",
13
16
  name: "Update Account",
14
- description: toSingleLineString(`
15
- Updates a Salesforce account, representing an individual account,
16
- which is an organization or person involved with your business (such as customers, competitors, and partners).
17
- See [Account SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_account.htm)
18
- and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
19
- `),
20
- version: "0.2.7",
17
+ description: `Updates a Salesforce account. [See the documentation](${docsLink})`,
18
+ version: "0.3.0",
21
19
  type: "action",
22
- props: {
23
- salesforce,
24
- AccountId: {
25
- type: "string",
26
- label: "Account ID",
27
- description: "ID of the Account to modify.",
20
+ methods: {
21
+ ...common.methods,
22
+ getObjectType() {
23
+ return "Account";
28
24
  },
29
- Name: {
30
- type: "string",
31
- label: "Name",
32
- description: "Name of the account. Maximum size is 255 characters. If the account has a record type of Person Account:\nThis value is the concatenation of the FirstName, MiddleName, LastName, and Suffix of the associated person contact.",
33
- optional: true,
25
+ getAdvancedProps() {
26
+ return account.extraProps;
34
27
  },
35
- selector: {
28
+ },
29
+ props: {
30
+ salesforce,
31
+ accountId: {
36
32
  propDefinition: [
37
33
  salesforce,
38
- "fieldSelector",
34
+ "recordId",
35
+ () => ({
36
+ objType: "Account",
37
+ nameField: "Name",
38
+ }),
39
39
  ],
40
- description: `${salesforce.propDefinitions.fieldSelector.description} Account`,
41
- options: () => Object.keys(account),
42
- reloadProps: true,
40
+ label: "Account ID",
41
+ description: "The Account to update.",
43
42
  },
44
- },
45
- additionalProps() {
46
- return this.additionalProps(this.selector, account);
43
+ ...props,
47
44
  },
48
45
  async run({ $ }) {
49
- const data = pickBy(pick(this, [
50
- "AccountId",
51
- "Name",
52
- ...this.selector,
53
- ]));
54
- const response = await this.salesforce.updateAccount({
46
+ /* eslint-disable no-unused-vars */
47
+ const {
48
+ salesforce,
49
+ getAdvancedProps,
50
+ getObjectType,
51
+ getAdditionalFields,
52
+ formatDateTimeProps,
53
+ accountId,
54
+ useAdvancedProps,
55
+ docsInfo,
56
+ dateInfo,
57
+ additionalFields,
58
+ ...data
59
+ } = this;
60
+ /* eslint-enable no-unused-vars */
61
+ const response = await salesforce.updateRecord("Account", {
55
62
  $,
56
- id: this.AccountId,
57
- data,
63
+ id: accountId,
64
+ data: {
65
+ ...data,
66
+ ...getAdditionalFields(),
67
+ },
58
68
  });
59
- $.export("$summary", `Successfully updated account ${this.AccountId}`);
69
+ $.export(
70
+ "$summary",
71
+ `Successfully updated account (ID: ${this.accountId})`,
72
+ );
60
73
  return response;
61
74
  },
62
75
  };
@@ -1,61 +1,80 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import contact from "../../common/sobjects/contact.mjs";
3
- import {
4
- pickBy, pick,
5
- } from "lodash-es";
6
- import { toSingleLineString } from "../../common/utils.mjs";
3
+ import { docsLink } from "../create-contact/create-contact.mjs";
7
4
 
8
- const { salesforce } = common.props;
5
+ const {
6
+ salesforce, ...props
7
+ } = getProps({
8
+ createOrUpdate: "update",
9
+ objType: contact,
10
+ docsLink,
11
+ showDateInfo: true,
12
+ });
9
13
 
10
14
  export default {
11
15
  ...common,
12
16
  key: "salesforce_rest_api-update-contact",
13
17
  name: "Update Contact",
14
- description: toSingleLineString(`
15
- Updates a Contact, which is a person associated with an account.
16
- See [Contact SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_contact.htm)
17
- and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
18
- `),
19
- version: "0.2.7",
18
+ description: `Updates a contact. [See the documentation](${docsLink})`,
19
+ version: "0.3.0",
20
20
  type: "action",
21
- props: {
22
- salesforce,
23
- ContactId: {
24
- type: "string",
25
- label: "Contact ID",
26
- description: "ID of the Contact to update.",
21
+ methods: {
22
+ ...common.methods,
23
+ getObjectType() {
24
+ return "Contact";
27
25
  },
28
- LastName: {
29
- type: "string",
30
- label: "Last Name",
31
- description: "Last name of the contact up to 80 characters.",
32
- optional: true,
26
+ getAdvancedProps() {
27
+ return contact.extraProps;
33
28
  },
34
- selector: {
29
+ },
30
+ props: {
31
+ salesforce,
32
+ contactId: {
35
33
  propDefinition: [
36
34
  salesforce,
37
- "fieldSelector",
35
+ "recordId",
36
+ () => ({
37
+ objType: "Contact",
38
+ nameField: "Name",
39
+ }),
38
40
  ],
39
- description: `${salesforce.propDefinitions.fieldSelector.description} Contact`,
40
- options: () => Object.keys(contact),
41
- reloadProps: true,
41
+ label: "Contact ID",
42
+ description: "The Contact to update.",
42
43
  },
43
- },
44
- additionalProps() {
45
- return this.additionalProps(this.selector, contact);
44
+ ...props,
46
45
  },
47
46
  async run({ $ }) {
48
- const data = pickBy(pick(this, [
49
- "ContactId",
50
- "LastName",
51
- ...this.selector,
52
- ]));
53
- const response = await this.salesforce.updateContact({
47
+ /* eslint-disable no-unused-vars */
48
+ const {
49
+ salesforce,
50
+ getAdvancedProps,
51
+ getObjectType,
52
+ getAdditionalFields,
53
+ formatDateTimeProps,
54
+ contactId,
55
+ useAdvancedProps,
56
+ docsInfo,
57
+ dateInfo,
58
+ additionalFields,
59
+ Birthdate,
60
+ ...data
61
+ } = this;
62
+ /* eslint-enable no-unused-vars */
63
+ const response = await salesforce.updateRecord("Contact", {
54
64
  $,
55
- id: this.ContactId,
56
- data,
65
+ id: contactId,
66
+ data: {
67
+ ...data,
68
+ ...formatDateTimeProps({
69
+ Birthdate,
70
+ }),
71
+ ...getAdditionalFields(),
72
+ },
57
73
  });
58
- $.export("$summary", `Successfully updated contact for ${this.ContactId}`);
74
+ $.export(
75
+ "$summary",
76
+ `Successfully updated contact (ID: ${this.contactId})`,
77
+ );
59
78
  return response;
60
79
  },
61
80
  };