@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,54 +1,58 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import campaign from "../../common/sobjects/campaign.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 = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_campaign.htm";
9
5
 
10
6
  export default {
11
7
  ...common,
12
8
  key: "salesforce_rest_api-create-campaign",
13
9
  name: "Create Campaign",
14
- description: toSingleLineString(`
15
- Creates a marketing campaign, such as a direct mail promotion, webinar, or trade show.
16
- See [Campaign SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_campaign.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 a marketing campaign. [See the documentation](${docsLink})`,
11
+ version: "0.3.0",
20
12
  type: "action",
21
- props: {
22
- salesforce,
23
- Name: {
24
- type: "string",
25
- label: "Name",
26
- description: "Required. Name of the campaign. Limit: is 80 characters.",
13
+ methods: {
14
+ ...common.methods,
15
+ getObjectType() {
16
+ return "Campaign";
27
17
  },
28
- selector: {
29
- propDefinition: [
30
- salesforce,
31
- "fieldSelector",
32
- ],
33
- description: `${salesforce.propDefinitions.fieldSelector.description} Campaign`,
34
- options: () => Object.keys(campaign),
35
- reloadProps: true,
36
- optional: true,
18
+ getAdvancedProps() {
19
+ return campaign.extraProps;
37
20
  },
38
21
  },
39
- additionalProps() {
40
- return this.additionalProps(this.selector, campaign);
41
- },
22
+ props: getProps({
23
+ objType: campaign,
24
+ docsLink,
25
+ showDateInfo: true,
26
+ }),
42
27
  async run({ $ }) {
43
- const data = pickBy(pick(this, [
44
- "Name",
45
- ...this.selector,
46
- ]));
47
- const response = await this.salesforce.createCampaign({
28
+ /* eslint-disable no-unused-vars, max-len */
29
+ const {
30
+ salesforce,
31
+ getAdvancedProps,
32
+ getObjectType,
33
+ getAdditionalFields,
34
+ formatDateTimeProps,
35
+ useAdvancedProps,
36
+ docsInfo,
37
+ dateInfo,
38
+ additionalFields,
39
+ StartDate,
40
+ EndDate,
41
+ ...data
42
+ } = this;
43
+ /* eslint-enable no-unused-vars, max-len */
44
+ const response = await salesforce.createRecord("Campaign", {
48
45
  $,
49
- data,
46
+ data: {
47
+ ...data,
48
+ ...formatDateTimeProps({
49
+ StartDate,
50
+ EndDate,
51
+ }),
52
+ ...getAdditionalFields(),
53
+ },
50
54
  });
51
- $.export("$summary", `Created campaign "${this.Name}"`);
55
+ $.export("$summary", `Successfully created campaign "${this.Name}"`);
52
56
  return response;
53
57
  },
54
58
  };
@@ -1,53 +1,57 @@
1
- import common from "../common/base.mjs";
2
- import salesforceCase from "../../common/sobjects/case.mjs";
3
- import {
4
- pickBy, pick,
5
- } from "lodash-es";
6
- import { toSingleLineString } from "../../common/utils.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
+ import caseObj from "../../common/sobjects/case.mjs";
7
3
 
8
- const { salesforce } = common.props;
4
+ const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_case.htm";
9
5
 
10
6
  export default {
11
7
  ...common,
12
8
  key: "salesforce_rest_api-create-case",
13
9
  name: "Create Case",
14
- description: toSingleLineString(`
15
- Creates a Salesforce case, which represents a customer issue or problem.
16
- See [Case SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_case.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 a Case, which represents a customer issue or problem. [See the documentation](${docsLink})`,
11
+ version: "0.3.0",
20
12
  type: "action",
21
- props: {
22
- salesforce,
23
- SuppliedEmail: {
24
- type: "string",
25
- label: "Supplied email",
26
- description: "The email address that was entered when the case was created. Label is Email.If your organization has an active auto-response rule, SuppliedEmail is required when creating a case via the API. Auto-response rules use the email in the contact specified by ContactId. If no email address is in the contact record, the email specified here is used.",
13
+ methods: {
14
+ ...common.methods,
15
+ getObjectType() {
16
+ return "Case";
27
17
  },
28
- selector: {
29
- propDefinition: [
30
- salesforce,
31
- "fieldSelector",
32
- ],
33
- description: `${salesforce.propDefinitions.fieldSelector.description} Case`,
34
- options: () => Object.keys(salesforceCase),
35
- reloadProps: true,
18
+ getAdvancedProps() {
19
+ return caseObj.extraProps;
36
20
  },
37
21
  },
38
- additionalProps() {
39
- return this.additionalProps(this.selector, salesforceCase);
40
- },
22
+ props: getProps({
23
+ objType: caseObj,
24
+ docsLink,
25
+ showDateInfo: true,
26
+ }),
41
27
  async run({ $ }) {
42
- const data = pickBy(pick(this, [
43
- "SuppliedEmail",
44
- ...this.selector,
45
- ]));
46
- const response = await this.salesforce.createCase({
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
+ SlaStartDate,
40
+ ...data
41
+ } = this;
42
+ /* eslint-enable no-unused-vars */
43
+ const response = await salesforce.createRecord("Case", {
47
44
  $,
48
- data,
45
+ data: {
46
+ ...data,
47
+ ...formatDateTimeProps({
48
+ SlaStartDate,
49
+ }),
50
+ ...getAdditionalFields(),
51
+ },
49
52
  });
50
- $.export("$summary", `Successfully created case for ${this.SuppliedEmail}`);
53
+ const summary = (this.SuppliedName && ` "${this.SuppliedName}"`) ?? (this.SuppliedEmail && ` with email ${this.SuppliedEmail}`) ?? "";
54
+ $.export("$summary", `Successfully created case${summary}`);
51
55
  return response;
52
56
  },
53
57
  };
@@ -1,49 +1,37 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import caseComment from "../../common/sobjects/caseComment.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 = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_casecomment.htm";
5
+
6
+ /* eslint-disable no-unused-vars */
7
+ const {
8
+ useAdvancedProps, ...props
9
+ } = getProps({
10
+ objType: caseComment,
11
+ docsLink,
12
+ });
13
+ /* eslint-enable no-unused-vars */
9
14
 
10
15
  export default {
11
16
  ...common,
12
17
  key: "salesforce_rest_api-create-casecomment",
13
- name: "Create CaseComment",
14
- description: toSingleLineString(`
15
- Creates a Case Comment that provides additional information about the associated Case.
16
- See [CaseComment SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_casecomment.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",
18
+ name: "Create Case Comment",
19
+ description: `Creates a Case Comment on a selected Case. [See the documentation](${docsLink})`,
20
+ version: "0.3.0",
20
21
  type: "action",
21
- props: {
22
- salesforce,
23
- ParentId: {
24
- type: "string",
25
- label: "Parent ID",
26
- description: "Required. ID of the parent Case of the CaseComment.",
27
- },
28
- selector: {
29
- propDefinition: [
30
- salesforce,
31
- "fieldSelector",
32
- ],
33
- description: `${salesforce.propDefinitions.fieldSelector.description} CaseComment`,
34
- options: () => Object.keys(caseComment),
35
- reloadProps: true,
36
- },
37
- },
38
- additionalProps() {
39
- return this.additionalProps(this.selector, caseComment);
40
- },
22
+ props,
41
23
  async run({ $ }) {
42
- const data = pickBy(pick(this, [
43
- "ParentId",
44
- ...this.selector,
45
- ]));
46
- const response = await this.salesforce.createCaseComment({
24
+ /* eslint-disable no-unused-vars */
25
+ const {
26
+ salesforce,
27
+ getAdvancedProps,
28
+ getAdditionalFields,
29
+ formatDateTimeProps,
30
+ docsInfo,
31
+ ...data
32
+ } = this;
33
+ /* eslint-enable no-unused-vars */
34
+ const response = await salesforce.createRecord("CaseComment", {
47
35
  $,
48
36
  data,
49
37
  });
@@ -1,51 +1,54 @@
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";
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_contact.htm";
9
5
 
10
6
  export default {
11
7
  ...common,
12
8
  key: "salesforce_rest_api-create-contact",
13
9
  name: "Create Contact",
14
- description: toSingleLineString(`
15
- Creates 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 [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 a contact. [See the documentation](${docsLink})`,
11
+ version: "0.3.0",
20
12
  type: "action",
21
- props: {
22
- salesforce,
23
- LastName: {
24
- type: "string",
25
- label: "Last name",
26
- description: "Last name of the contact up to 80 characters.",
13
+ methods: {
14
+ ...common.methods,
15
+ getObjectType() {
16
+ return "Contact";
27
17
  },
28
- selector: {
29
- propDefinition: [
30
- salesforce,
31
- "fieldSelector",
32
- ],
33
- description: `${salesforce.propDefinitions.fieldSelector.description} Contact`,
34
- options: () => Object.keys(contact),
35
- reloadProps: true,
18
+ getAdvancedProps() {
19
+ return contact.extraProps;
36
20
  },
37
21
  },
38
- additionalProps() {
39
- return this.additionalProps(this.selector, contact);
40
- },
22
+ props: getProps({
23
+ objType: contact,
24
+ docsLink,
25
+ showDateInfo: true,
26
+ }),
41
27
  async run({ $ }) {
42
- const data = pickBy(pick(this, [
43
- "LastName",
44
- ...this.selector,
45
- ]));
46
- const response = await this.salesforce.createContact({
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
+ Birthdate,
40
+ ...data
41
+ } = this;
42
+ /* eslint-enable no-unused-vars */
43
+ const response = await salesforce.createRecord("Contact", {
47
44
  $,
48
- data,
45
+ data: {
46
+ ...data,
47
+ ...formatDateTimeProps({
48
+ Birthdate,
49
+ }),
50
+ ...getAdditionalFields(),
51
+ },
49
52
  });
50
53
  $.export("$summary", `Successfully created contact "${this.LastName}"`);
51
54
  return response;
@@ -1,80 +1,71 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
2
- import {
3
- removeNullEntries, toSingleLineString,
4
- } from "../../common/utils.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
+ import event from "../../common/sobjects/event.mjs";
3
+
4
+ const docsLink =
5
+ "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_event.htm";
5
6
 
6
7
  export default {
8
+ ...common,
7
9
  key: "salesforce_rest_api-create-event",
8
10
  name: "Create Event",
9
- description: toSingleLineString(`
10
- Creates an event, which represents an event in the calendar.
11
- See [Event SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_event.htm)
12
- and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
13
- `),
14
- version: "0.2.7",
11
+ description: `Creates an event. [See the documentation](${docsLink})`,
12
+ version: "0.3.0",
15
13
  type: "action",
16
- props: {
17
- salesforce,
18
- IsAllDayEvent: {
19
- type: "boolean",
20
- label: "All-Day Event",
21
- description: "Indicates whether the ActivityDate field (true) or the ActivityDateTime field (false) is used to define the date or time of the event.",
22
- reloadProps: true,
23
- },
24
- AcceptedEventInviteeIds: {
25
- propDefinition: [
26
- salesforce,
27
- "AcceptedEventInviteeIds",
28
- ],
29
- },
30
- Description: {
31
- type: "string",
32
- label: "Description",
33
- description: "Contains a text description of the event. Limit: 32,000 characters.",
14
+ methods: {
15
+ ...common.methods,
16
+ getObjectType() {
17
+ return "Event";
34
18
  },
35
- Subject: {
36
- type: "string",
37
- label: "Subject",
38
- description: "The subject line of the event, such as Call, Email, or Meeting. Limit: 255 characters.",
19
+ getAdvancedProps() {
20
+ return event.extraProps;
39
21
  },
40
22
  },
41
- async additionalProps() {
42
- const props = {};
43
- if (this.IsAllDayEvent) {
44
- props.ActivityDate = {
45
- type: "string",
46
- label: "Due Date Only (YYYY/MM/DD)",
47
- description: "Contains the event's due date if the IsAllDayEvent flag is set to true.",
48
- };
49
- } else {
50
- props.ActivityDateTime = {
51
- type: "string",
52
- label: "Due Date Time",
53
- description: "Contains the event's due date if the IsAllDayEvent flag is set to false. The time portion of this field is always transferred in the Coordinated Universal Time (UTC) time zone. Translate the time portion to or from a local time zone for the user or the application, as appropriate.",
54
- };
55
- props.DurationInMinutes = {
56
- type: "integer",
57
- label: "Duration in minutes",
58
- description: "Contains the event length, in minutes.",
59
- };
60
- }
61
- return props;
62
- },
23
+ props: getProps({
24
+ objType: event,
25
+ docsLink,
26
+ showDateInfo: true,
27
+ }),
63
28
  async run({ $ }) {
64
- const data = removeNullEntries({
65
- IsAllDayEvent: this.IsAllDayEvent,
66
- AcceptedEventInviteeIds: this.AcceptedEventInviteeIds,
67
- Description: this.Description,
68
- Subject: this.Subject,
69
- ActivityDate: this.ActivityDate && new Date(this.ActivityDate).toUTCString(),
70
- ActivityDateTime: this.ActivityDateTime,
71
- DurationInMinutes: this.DurationInMinutes,
72
- });
73
- const response = await this.salesforce.createEvent({
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
+ EndDateTime,
42
+ RecurrenceEndDateOnly,
43
+ RecurrenceStartDateTime,
44
+ ReminderDateTime,
45
+ StartDateTime,
46
+ RecurrenceDayOfWeekMask,
47
+ ...data
48
+ } = this;
49
+ /* eslint-enable no-unused-vars */
50
+ const response = await salesforce.createRecord("Event", {
74
51
  $,
75
- data,
52
+ data: {
53
+ ...data,
54
+ ...formatDateTimeProps({
55
+ ActivityDate,
56
+ EndDateTime,
57
+ RecurrenceEndDateOnly,
58
+ RecurrenceStartDateTime,
59
+ ReminderDateTime,
60
+ StartDateTime,
61
+ }),
62
+ RecurrenceDayOfWeekMask: RecurrenceDayOfWeekMask?.reduce?.((acc, val) => acc + val, 0),
63
+ ...getAdditionalFields(),
64
+ },
76
65
  });
77
- $.export("$summary", "Succcessfully created event");
66
+ $.export("$summary", `Succcessfully created event${this.Subject
67
+ ? ` "${this.Subject}"`
68
+ : ""}`);
78
69
  return response;
79
70
  },
80
71
  };
@@ -1,59 +1,51 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import lead from "../../common/sobjects/lead.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 = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_lead.htm";
9
5
 
10
6
  export default {
11
7
  ...common,
12
8
  key: "salesforce_rest_api-create-lead",
13
9
  name: "Create Lead",
14
- description: toSingleLineString(`
15
- Creates a lead, which represents a prospect or lead.
16
- See [Lead SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_lead.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 a lead. [See the documentation](${docsLink})`,
11
+ version: "0.3.0",
20
12
  type: "action",
21
- props: {
22
- salesforce,
23
- Company: {
24
- type: "string",
25
- label: "Company",
26
- description: "The lead's company. Note If person account record types have been enabled, and if the value of Company is null, the lead converts to a person account.",
13
+ methods: {
14
+ ...common.methods,
15
+ getObjectType() {
16
+ return "Lead";
27
17
  },
28
- LastName: {
29
- type: "string",
30
- label: "Last name",
31
- description: "Required. Last name of the lead up to 80 characters.",
18
+ getAdvancedProps() {
19
+ return lead.extraProps;
32
20
  },
33
- selector: {
34
- propDefinition: [
35
- salesforce,
36
- "fieldSelector",
37
- ],
38
- description: `${salesforce.propDefinitions.fieldSelector.description} Lead`,
39
- options: () => Object.keys(lead),
40
- reloadProps: true,
41
- },
42
- },
43
- additionalProps() {
44
- return this.additionalProps(this.selector, lead);
45
21
  },
22
+ props: getProps({
23
+ objType: lead,
24
+ docsLink,
25
+ }),
46
26
  async run({ $ }) {
47
- const data = pickBy(pick(this, [
48
- "Company",
49
- "LastName",
50
- ...this.selector,
51
- ]));
52
- const response = await this.salesforce.createLead({
27
+ /* eslint-disable no-unused-vars */
28
+ const {
29
+ salesforce,
30
+ getAdvancedProps,
31
+ getObjectType,
32
+ getAdditionalFields,
33
+ formatDateTimeProps,
34
+ useAdvancedProps,
35
+ docsInfo,
36
+ dateInfo,
37
+ additionalFields,
38
+ ...data
39
+ } = this;
40
+ /* eslint-enable no-unused-vars */
41
+ const response = await salesforce.createRecord("Lead", {
53
42
  $,
54
- data,
43
+ data: {
44
+ ...data,
45
+ ...getAdditionalFields(),
46
+ },
55
47
  });
56
- $.export("$summary", `Successfully created lead for ${this.Company}`);
48
+ $.export("$summary", `Successfully created lead "${this.LastName}"`);
57
49
  return response;
58
50
  },
59
51
  };
@@ -1,55 +1,36 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import note from "../../common/sobjects/note.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 = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_note.htm";
5
+
6
+ /* eslint-disable no-unused-vars */
7
+ const {
8
+ useAdvancedProps, ...props
9
+ } = getProps({
10
+ objType: note,
11
+ docsLink,
12
+ });
13
+ /* eslint-enable no-unused-vars */
9
14
 
10
15
  export default {
11
16
  ...common,
12
17
  key: "salesforce_rest_api-create-note",
13
18
  name: "Create Note",
14
- description: toSingleLineString(`
15
- Creates a note, which is text associated with a custom object or a standard object, such as a Contact, Contract, or Opportunity.
16
- See [Note SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_note.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",
19
+ description: `Creates a note. [See the documentation](${docsLink})`,
20
+ version: "0.3.0",
20
21
  type: "action",
21
- props: {
22
- salesforce,
23
- ParentId: {
24
- type: "string",
25
- label: "Parent ID",
26
- description: "ID of the object associated with the note.",
27
- },
28
- Title: {
29
- type: "string",
30
- label: "Title",
31
- description: "Title of the note.",
32
- },
33
- selector: {
34
- propDefinition: [
35
- salesforce,
36
- "fieldSelector",
37
- ],
38
- description: `${salesforce.propDefinitions.fieldSelector.description} Note`,
39
- options: () => Object.keys(note),
40
- reloadProps: true,
41
- },
42
- },
43
- additionalProps() {
44
- return this.additionalProps(this.selector, note);
45
- },
22
+ props,
46
23
  async run({ $ }) {
47
- const data = pickBy(pick(this, [
48
- "ParentId",
49
- "Title",
50
- ...this.selector,
51
- ]));
52
- const response = await this.salesforce.createNote({
24
+ /* eslint-disable no-unused-vars */
25
+ const {
26
+ salesforce,
27
+ getAdvancedProps,
28
+ getAdditionalFields,
29
+ formatDateTimeProps,
30
+ docsInfo, ...data
31
+ } = this;
32
+ /* eslint-enable no-unused-vars */
33
+ const response = await salesforce.createRecord("Note", {
53
34
  $,
54
35
  data,
55
36
  });