-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - salesforce_rest_api #17879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
components/salesforce_rest_api/actions/get-case/get-case.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-get-case", | ||
| name: "Get Case", | ||
| description: "Retrieves a case by its ID. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| caseId: { | ||
| propDefinition: [ | ||
| salesforce, | ||
| "recordId", | ||
| () => ({ | ||
| objType: "Case", | ||
| }), | ||
| ], | ||
| label: "Case ID", | ||
| description: "The case ID to retrieve", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const fields = (await this.salesforce.getFieldsForObjectType("Case")).map(({ name }) => name); | ||
|
|
||
| let query = `SELECT ${fields.join(", ")} FROM Case WHERE Id = '${this.caseId}'`; | ||
|
|
||
| const { records } = await this.salesforce.query({ | ||
| $, | ||
| query, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully retrieved case with ID ${this.caseId}`); | ||
| return records[0]; | ||
| }, | ||
| }; | ||
34 changes: 34 additions & 0 deletions
34
components/salesforce_rest_api/actions/get-user/get-user.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-get-user", | ||
| name: "Get User", | ||
| description: "Retrieves a user by their ID. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| userId: { | ||
| propDefinition: [ | ||
| salesforce, | ||
| "recordId", | ||
| () => ({ | ||
| objType: "User", | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const fields = (await this.salesforce.getFieldsForObjectType("User")).map(({ name }) => name); | ||
|
|
||
| let query = `SELECT ${fields.join(", ")} FROM User WHERE Id = '${this.userId}'`; | ||
|
|
||
| const { records } = await this.salesforce.query({ | ||
| $, | ||
| query, | ||
| }); | ||
|
|
||
| $.export("$summary", `Sucessfully retrieved user with ID ${this.userId}`); | ||
| return records[0]; | ||
| }, | ||
| }; |
32 changes: 32 additions & 0 deletions
32
components/salesforce_rest_api/actions/list-case-comments/list-case-comments.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-list-case-comments", | ||
| name: "List Case Comments", | ||
| description: "Lists all comments for a case. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| caseId: { | ||
| propDefinition: [ | ||
| salesforce, | ||
| "recordId", | ||
| () => ({ | ||
| objType: "Case", | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const fields = (await this.salesforce.getFieldsForObjectType("CaseComment")).map(({ name }) => name); | ||
| let query = `SELECT ${fields.join(", ")} FROM CaseComment WHERE ParentId = '${this.caseId}'`; | ||
|
|
||
| const { records } = await this.salesforce.query({ | ||
| $, | ||
| query, | ||
| }); | ||
| $.export("$summary", `Sucessfully retrieved ${records.length} comments for case with ID ${this.caseId}`); | ||
| return records; | ||
| }, | ||
| }; |
38 changes: 38 additions & 0 deletions
38
components/salesforce_rest_api/actions/list-email-messages/list-email-messages.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-list-email-messages", | ||
| name: "List Email Messages", | ||
| description: "Lists all email messages for a case. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| caseId: { | ||
| propDefinition: [ | ||
| salesforce, | ||
| "recordId", | ||
| () => ({ | ||
| objType: "Case", | ||
| }), | ||
| ], | ||
| label: "Case ID", | ||
| description: "The ID of the case to retrieve email messages for", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const fields = (await this.salesforce.getFieldsForObjectType("EmailMessage")).map(({ name }) => name); | ||
| let query = `SELECT ${fields.join(", ")} FROM EmailMessage`; | ||
| if (this.caseId) { | ||
| query += ` WHERE RelatedToId = '${this.caseId}'`; | ||
| } | ||
|
|
||
| const { records } = await this.salesforce.query({ | ||
| $, | ||
| query, | ||
| }); | ||
| $.export("$summary", `Sucessfully retrieved ${records.length} email messages for case with ID ${this.caseId}`); | ||
| return records; | ||
| }, | ||
| }; |
23 changes: 23 additions & 0 deletions
23
components/salesforce_rest_api/actions/list-email-templates/list-email-templates.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-list-email-templates", | ||
| name: "List Email Templates", | ||
| description: "Lists all email templates. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailtemplate.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| }, | ||
| async run({ $ }) { | ||
| const fields = (await this.salesforce.getFieldsForObjectType("EmailTemplate")).map(({ name }) => name); | ||
| const query = `SELECT ${fields.join(", ")} FROM EmailTemplate`; | ||
|
|
||
| const { records } = await this.salesforce.query({ | ||
| $, | ||
| query, | ||
| }); | ||
| $.export("$summary", `Sucessfully retrieved ${records.length} email templates`); | ||
| return records; | ||
| }, | ||
| }; |
23 changes: 23 additions & 0 deletions
23
components/salesforce_rest_api/actions/list-knowledge-articles/list-knowledge-articles.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-list-knowledge-articles", | ||
| name: "List Knowledge Articles", | ||
| description: "Lists all knowledge articles. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_knowledgearticle.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| }, | ||
| async run({ $ }) { | ||
| const fields = (await this.salesforce.getFieldsForObjectType("KnowledgeArticle")).map(({ name }) => name); | ||
| const query = `SELECT ${fields.join(", ")} FROM KnowledgeArticle`; | ||
|
|
||
| const { records } = await this.salesforce.query({ | ||
| $, | ||
| query, | ||
| }); | ||
| $.export("$summary", `Sucessfully retrieved ${records.length} knowledge articles`); | ||
| return records; | ||
| }, | ||
| }; |
60 changes: 60 additions & 0 deletions
60
components/salesforce_rest_api/actions/send-email/send-email.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-send-email", | ||
| name: "Send Email", | ||
| description: "Sends an email. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_obj_email_simple.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| emailAddress: { | ||
| type: "string", | ||
| label: "Email Address", | ||
| description: "The email address to send the email to", | ||
| }, | ||
| emailSubject: { | ||
| type: "string", | ||
| label: "Subject", | ||
| description: "The subject of the email", | ||
| }, | ||
| emailBody: { | ||
| type: "string", | ||
| label: "Body", | ||
| description: "The body of the email", | ||
| }, | ||
| logEmailOnSend: { | ||
| type: "boolean", | ||
| label: "Log Email on Send", | ||
| description: "Indicates whether to log the email on the specified records’ activity time lines", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| sendEmail(opts = {}) { | ||
| return this.salesforce._makeRequest({ | ||
| url: `${this.salesforce._baseApiVersionUrl()}/actions/standard/emailSimple`, | ||
| method: "POST", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.sendEmail({ | ||
| $, | ||
| data: { | ||
| inputs: [ | ||
| { | ||
| emailAddresses: this.emailAddress, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| emailSubject: this.emailSubject, | ||
| emailBody: this.emailBody, | ||
| senderType: "CurrentUser", | ||
| logEmailOnSend: this.logEmailOnSend, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
| $.export("$summary", `Email sent to ${this.emailAddress}`); | ||
| return response; | ||
| }, | ||
| }; | ||
81 changes: 81 additions & 0 deletions
81
components/salesforce_rest_api/actions/update-email-template/update-email-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { | ||
| convertFieldsToProps, getAdditionalFields, | ||
| } from "../../common/props-utils.mjs"; | ||
| import salesforce from "../../salesforce_rest_api.app.mjs"; | ||
| import { additionalFields } from "../common/base-create-update.mjs"; | ||
|
|
||
| export default { | ||
| key: "salesforce_rest_api-update-email-template", | ||
| name: "Update Email Template", | ||
| description: "Updates an email template. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_update_fields.htm)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salesforce, | ||
| recordId: { | ||
| propDefinition: [ | ||
| salesforce, | ||
| "recordId", | ||
| () => ({ | ||
| objType: "EmailTemplate", | ||
| }), | ||
| ], | ||
| description: "The email template to update.", | ||
| }, | ||
| fieldsToUpdate: { | ||
| propDefinition: [ | ||
| salesforce, | ||
| "fieldsToUpdate", | ||
| () => ({ | ||
| objType: "EmailTemplate", | ||
| }), | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| getAdditionalFields, | ||
| convertFieldsToProps, | ||
| }, | ||
| async additionalProps() { | ||
| const { fieldsToUpdate } = this; | ||
| const fields = await this.salesforce.getFieldsForObjectType("EmailTemplate"); | ||
|
|
||
| const selectedFields = fields.filter(({ name }) => fieldsToUpdate.includes(name)); | ||
| const selectedFieldProps = this.convertFieldsToProps(selectedFields); | ||
|
|
||
| return { | ||
| docsInfo: { | ||
| type: "alert", | ||
| alertType: "info", | ||
| content: "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailtemplate.htm) for information on all available fields.", | ||
| }, | ||
| ...selectedFieldProps, | ||
| additionalFields, | ||
| }; | ||
| }, | ||
| async run({ $ }) { | ||
| /* eslint-disable no-unused-vars */ | ||
| const { | ||
| salesforce, | ||
| recordId, | ||
| fieldsToUpdate, | ||
| getAdditionalFields: getData, | ||
| convertFieldsToProps, | ||
| docsInfo, | ||
| additionalFields, | ||
| ...data | ||
| } = this; | ||
| /* eslint-enable no-unused-vars */ | ||
| const response = await this.salesforce.updateRecord("EmailTemplate", { | ||
| $, | ||
| id: recordId, | ||
| data: { | ||
| ...data, | ||
| ...getData(), | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully updated Email Template record (ID: ${recordId})`); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
components/salesforce_rest_api/sources/case-updated-instant/case-updated-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import common from "../common/common-updated-record.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| type: "source", | ||
| name: "Case Updated (Instant, of Selectable Type)", | ||
| key: "salesforce_rest_api-case-updated-instant", | ||
| description: "Emit new event when a case is updated. [See the documentation](https://sforce.co/3yPSJZy)", | ||
| version: "0.0.1", | ||
| props: { | ||
| salesforce: common.props.salesforce, | ||
| db: "$.service.db", | ||
| http: { | ||
| type: "$.interface.http", | ||
| customResponse: true, | ||
| }, | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| description: "The timer is only used as a fallback if instant event delivery (webhook) is not available.", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| fieldsToObtain: { | ||
| propDefinition: [ | ||
| common.props.salesforce, | ||
| "fieldsToObtain", | ||
| () => ({ | ||
| objType: "Case", | ||
| }), | ||
| ], | ||
| optional: true, | ||
| description: "Select the field(s) to be retrieved for the records. Only applicable if the source is running on a timer. If running on a webhook, or if not specified, all fields will be retrieved.", | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getObjectType() { | ||
| return "Case"; | ||
| }, | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.