@pipedream/salesforce_rest_api 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/add-contact-to-campaign/add-contact-to-campaign.mjs +7 -2
- package/actions/add-lead-to-campaign/add-lead-to-campaign.mjs +7 -2
- package/actions/convert-soap-xml-to-json/convert-soap-xml-to-json.mjs +7 -2
- package/actions/create-account/create-account.mjs +7 -2
- package/actions/create-accounts-batch/create-accounts-batch.mjs +8 -2
- package/actions/create-attachment/create-attachment.mjs +7 -2
- package/actions/create-campaign/create-campaign.mjs +7 -2
- package/actions/create-case/create-case.mjs +7 -2
- package/actions/create-casecomment/create-casecomment.mjs +7 -2
- package/actions/create-contact/create-contact.mjs +7 -2
- package/actions/create-content-note/create-content-note.mjs +9 -2
- package/actions/create-crm-record/create-crm-record.mjs +5 -3
- package/actions/create-event/create-event.mjs +7 -2
- package/actions/create-lead/create-lead.mjs +7 -2
- package/actions/create-note/create-note.mjs +7 -2
- package/actions/create-opportunities-batch/create-opportunities-batch.mjs +9 -2
- package/actions/create-opportunity/create-opportunity.mjs +7 -2
- package/actions/create-record/create-record.mjs +7 -2
- package/actions/create-task/create-task.mjs +7 -2
- package/actions/create-user/create-user.mjs +7 -2
- package/actions/delete-crm-record/delete-crm-record.mjs +6 -4
- package/actions/delete-note/delete-note.mjs +7 -2
- package/actions/delete-opportunity/delete-opportunity.mjs +7 -2
- package/actions/delete-record/delete-record.mjs +7 -2
- package/actions/describe-object/describe-object.mjs +5 -3
- package/actions/find-records/find-records.mjs +49 -12
- package/actions/get-case/get-case.mjs +7 -2
- package/actions/get-current-user/get-current-user.mjs +2 -1
- package/actions/get-knowledge-articles/get-knowledge-articles.mjs +7 -2
- package/actions/get-knowledge-data-category-groups/get-knowledge-data-category-groups.mjs +7 -2
- package/actions/get-record-by-id/get-record-by-id.mjs +7 -2
- package/actions/get-related-records/get-related-records.mjs +5 -3
- package/actions/get-user/get-user.mjs +7 -2
- package/actions/get-user-info/get-user-info.mjs +5 -3
- package/actions/insert-blob-data/insert-blob-data.mjs +7 -2
- package/actions/list-case-comments/list-case-comments.mjs +51 -7
- package/actions/list-case-feed-items/list-case-feed-items.mjs +73 -0
- package/actions/list-cases/list-cases.mjs +131 -0
- package/actions/list-email-messages/list-email-messages.mjs +57 -10
- package/actions/list-email-templates/list-email-templates.mjs +45 -6
- package/actions/list-knowledge-articles/list-knowledge-articles.mjs +45 -6
- package/actions/list-object-fields/list-object-fields.mjs +7 -2
- package/actions/list-objects/list-objects.mjs +5 -3
- package/actions/post-feed-to-chatter/post-feed-to-chatter.mjs +7 -2
- package/actions/search-string/search-string.mjs +7 -2
- package/actions/send-email/send-email.mjs +7 -2
- package/actions/soql-query/soql-query.mjs +5 -3
- package/actions/soql-search/soql-search.mjs +7 -2
- package/actions/sosl-search/sosl-search.mjs +7 -2
- package/actions/text-search/text-search.mjs +5 -3
- package/actions/update-account/update-account.mjs +7 -2
- package/actions/update-accounts-batch/update-accounts-batch.mjs +9 -2
- package/actions/update-contact/update-contact.mjs +7 -2
- package/actions/update-content-note/update-content-note.mjs +9 -2
- package/actions/update-crm-record/update-crm-record.mjs +5 -3
- package/actions/update-email-template/update-email-template.mjs +7 -2
- package/actions/update-note/update-note.mjs +7 -2
- package/actions/update-opportunities-batch/update-opportunities-batch.mjs +9 -2
- package/actions/update-opportunity/update-opportunity.mjs +7 -2
- package/actions/update-record/update-record.mjs +7 -2
- package/actions/upsert-record/upsert-record.mjs +7 -2
- package/common/constants.mjs +52 -0
- package/common/soql.mjs +96 -0
- package/package.json +1 -1
- package/sources/case-updated-instant/case-updated-instant.mjs +1 -1
- package/sources/email-template-updated-instant/email-template-updated-instant.mjs +1 -1
- package/sources/knowledge-article-updated-instant/knowledge-article-updated-instant.mjs +1 -1
- package/sources/new-case-instant/new-case-instant.mjs +1 -1
- package/sources/new-email-template-instant/new-email-template-instant.mjs +1 -1
- package/sources/new-feed-comment/new-feed-comment.mjs +1 -1
- package/sources/new-feed-item/new-feed-item.mjs +1 -1
- package/sources/new-knowledge-article-instant/new-knowledge-article-instant.mjs +1 -1
- package/sources/new-record-instant/new-record-instant.mjs +1 -1
- package/sources/record-deleted-instant/record-deleted-instant.mjs +1 -1
- package/sources/record-updated-instant/record-updated-instant.mjs +1 -1
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "salesforce_rest_api-get-case",
|
|
5
6
|
name: "Get Case",
|
|
6
|
-
description: "
|
|
7
|
-
|
|
7
|
+
description: "Retrieve one Salesforce case by its record ID."
|
|
8
|
+
+ " Use **List Cases** to find the ID first, or when you want to search cases rather than fetch a known one."
|
|
9
|
+
+ " Use **List Case Feed Items** and **List Case Comments** to read the case's activity and comment thread."
|
|
10
|
+
+ " "
|
|
11
|
+
+ "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)",
|
|
12
|
+
version: "0.0.6",
|
|
8
13
|
annotations: {
|
|
9
14
|
destructiveHint: false,
|
|
10
15
|
openWorldHint: true,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "salesforce_rest_api-get-current-user",
|
|
5
6
|
name: "Get Current User",
|
|
6
7
|
description: "Returns the authenticated Salesforce user's ID, name, email, and organization ID. Call this first when the user says 'my leads', 'my opportunities', 'my cases', or any first-person query. Use `user_id` as the OwnerId filter in **SOQL Search** (e.g. `WHERE OwnerId = '{user_id}'`) and `organization_id` to construct Salesforce UI URLs. [See the documentation](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_using_userinfo_endpoint.htm).",
|
|
7
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
8
9
|
type: "action",
|
|
9
10
|
annotations: {
|
|
10
11
|
destructiveHint: false,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import common from "../common/knowledge.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
...common,
|
|
5
6
|
key: "salesforce_rest_api-get-knowledge-articles",
|
|
6
7
|
name: "Get Knowledge Articles",
|
|
7
|
-
description: "
|
|
8
|
-
|
|
8
|
+
description: "Retrieve a page of online Knowledge articles for a language and data category, by search or query."
|
|
9
|
+
+ " Use **List Knowledge Data Category Groups** to discover valid category values first, and **List Knowledge Articles** to browse article records instead."
|
|
10
|
+
+ " Returns published article content, so responses can be large - narrow by category or search term."
|
|
11
|
+
+ " "
|
|
12
|
+
+ "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.knowledge_dev.meta/knowledge_dev/sforce_api_rest_retrieve_article_list.htm)",
|
|
13
|
+
version: "0.0.4",
|
|
9
14
|
annotations: {
|
|
10
15
|
destructiveHint: false,
|
|
11
16
|
openWorldHint: true,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import common from "../common/knowledge.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
...common,
|
|
5
6
|
key: "salesforce_rest_api-get-knowledge-data-category-groups",
|
|
6
7
|
name: "Get Knowledge Data Category Groups",
|
|
7
|
-
description: "
|
|
8
|
-
|
|
8
|
+
description: "List the Knowledge data category groups visible to the current user."
|
|
9
|
+
+ " Call this before **Get Knowledge Articles** to discover the valid category group and category names to filter by."
|
|
10
|
+
+ " Returns only categories the authenticated user can see, so results vary per user."
|
|
11
|
+
+ " "
|
|
12
|
+
+ "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.knowledge_dev.meta/knowledge_dev/resources_knowledge_support_dcgroups.htm)",
|
|
13
|
+
version: "0.0.4",
|
|
9
14
|
annotations: {
|
|
10
15
|
destructiveHint: false,
|
|
11
16
|
openWorldHint: true,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "salesforce_rest_api-get-record-by-id",
|
|
5
6
|
name: "Get Record by ID",
|
|
6
|
-
description: "
|
|
7
|
-
|
|
7
|
+
description: "Retrieve one Salesforce record of any object type by its record ID."
|
|
8
|
+
+ " Use **Find Records** to look up records by criteria, or **SOQL Query** when you need related fields or a filtered set."
|
|
9
|
+
+ " Use **List Objects** to discover object types if you are unsure of the type name."
|
|
10
|
+
+ " "
|
|
11
|
+
+ "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)",
|
|
12
|
+
version: "0.0.3",
|
|
8
13
|
type: "action",
|
|
9
14
|
annotations: {
|
|
10
15
|
destructiveHint: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// x-pd-ai: optimized
|
|
2
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
@@ -11,8 +11,10 @@ export default {
|
|
|
11
11
|
+ " Contact → Cases, Opportunities, Tasks;"
|
|
12
12
|
+ " Opportunity → OpportunityLineItems, Tasks."
|
|
13
13
|
+ " Use **Describe Object** to discover available relationship names if unsure"
|
|
14
|
-
+ " (look for `relationshipName` on reference fields)."
|
|
15
|
-
|
|
14
|
+
+ " (look for `relationshipName` on reference fields)."
|
|
15
|
+
+ " "
|
|
16
|
+
+ "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_relationships.htm)",
|
|
17
|
+
version: "0.0.2",
|
|
16
18
|
type: "action",
|
|
17
19
|
annotations: {
|
|
18
20
|
readOnlyHint: true,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "salesforce_rest_api-get-user",
|
|
5
6
|
name: "Get User",
|
|
6
|
-
description: "
|
|
7
|
-
|
|
7
|
+
description: "Retrieve one Salesforce user by their record ID."
|
|
8
|
+
+ " Use **Get Current User** for the authenticated user instead of looking up an ID."
|
|
9
|
+
+ " Record owner fields such as `OwnerId` hold user IDs - pass one here to resolve it to a name and email."
|
|
10
|
+
+ " "
|
|
11
|
+
+ "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)",
|
|
12
|
+
version: "0.0.6",
|
|
8
13
|
annotations: {
|
|
9
14
|
destructiveHint: false,
|
|
10
15
|
openWorldHint: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// x-pd-ai: optimized
|
|
2
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
@@ -9,8 +9,10 @@ export default {
|
|
|
9
9
|
+ " **Must be called before any query that uses first-person language ('my', 'I', 'me').**"
|
|
10
10
|
+ " The `userId` can be used as an `OwnerId` filter in SOQL queries (e.g. `WHERE OwnerId = '{userId}'`)."
|
|
11
11
|
+ " The `instanceUrl` is needed to construct clickable links to Salesforce records:"
|
|
12
|
-
+ " `{instanceUrl}/lightning/r/{objectType}/{recordId}/view`."
|
|
13
|
-
|
|
12
|
+
+ " `{instanceUrl}/lightning/r/{objectType}/{recordId}/view`."
|
|
13
|
+
+ " "
|
|
14
|
+
+ "[See the documentation](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_using_userinfo_endpoint.htm&type=5)",
|
|
15
|
+
version: "0.0.2",
|
|
14
16
|
type: "action",
|
|
15
17
|
annotations: {
|
|
16
18
|
readOnlyHint: true,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "salesforce_rest_api-insert-blob-data",
|
|
5
6
|
name: "Insert Blob Data",
|
|
6
|
-
description: "
|
|
7
|
-
|
|
7
|
+
description: "Upload binary file data to a Salesforce object such as `ContentVersion` or `Attachment`."
|
|
8
|
+
+ " Use this for Salesforce Files (`ContentVersion`); use **Create Attachment** only for the legacy attachment object."
|
|
9
|
+
+ " The file content must be supplied as a file path or URL, not as raw bytes in the request."
|
|
10
|
+
+ " "
|
|
11
|
+
+ "[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm)",
|
|
12
|
+
version: "0.2.13",
|
|
8
13
|
annotations: {
|
|
9
14
|
destructiveHint: false,
|
|
10
15
|
openWorldHint: true,
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
|
+
import {
|
|
5
|
+
assertSalesforceId, buildFieldList, truncationNote,
|
|
6
|
+
} from "../../common/soql.mjs";
|
|
2
7
|
|
|
3
8
|
export default {
|
|
4
9
|
key: "salesforce_rest_api-list-case-comments",
|
|
5
10
|
name: "List Case Comments",
|
|
6
|
-
description: "
|
|
7
|
-
|
|
11
|
+
description: "List the comments on a Salesforce case, newest first."
|
|
12
|
+
+ " Use this for the case's comment thread only - use **List Case Feed Items** for the full activity trail (status changes, logged calls, emails) or **List Email Messages** for emails on the case."
|
|
13
|
+
+ " Find the case ID with **List Cases** first."
|
|
14
|
+
+ " For example, case ID `5005g00001ABCDeAAI` with `Limit` `20` returns that case's twenty most recent comments."
|
|
15
|
+
+ " [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_casecomment.htm)",
|
|
16
|
+
version: "0.1.0",
|
|
8
17
|
annotations: {
|
|
9
18
|
destructiveHint: false,
|
|
10
19
|
openWorldHint: true,
|
|
@@ -18,20 +27,55 @@ export default {
|
|
|
18
27
|
salesforce,
|
|
19
28
|
"recordId",
|
|
20
29
|
() => ({
|
|
21
|
-
objType:
|
|
30
|
+
objType: constants.OBJECT_TYPE.CASE,
|
|
22
31
|
}),
|
|
23
32
|
],
|
|
33
|
+
label: "Case ID",
|
|
34
|
+
description: "The ID of the case to retrieve comments for (15- or 18-character Salesforce ID, e.g. `5005g00001ABCDeAAI`). Use the **List Cases** action to retrieve case IDs.",
|
|
35
|
+
},
|
|
36
|
+
fields: {
|
|
37
|
+
propDefinition: [
|
|
38
|
+
salesforce,
|
|
39
|
+
"fieldsToObtain",
|
|
40
|
+
() => ({
|
|
41
|
+
objType: constants.OBJECT_TYPE.CASE_COMMENT,
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
label: "Fields",
|
|
45
|
+
description: "The CaseComment fields to return. Defaults to every field on the object. `Id` is always returned.",
|
|
46
|
+
optional: true,
|
|
47
|
+
},
|
|
48
|
+
limit: {
|
|
49
|
+
type: "integer",
|
|
50
|
+
label: "Limit",
|
|
51
|
+
description: `The maximum number of comments to return. Valid values are integers from 1 through ${constants.MAX_LIMIT}. Omit to return every comment Salesforce sends in one batch.`,
|
|
52
|
+
min: 1,
|
|
53
|
+
max: constants.MAX_LIMIT,
|
|
54
|
+
optional: true,
|
|
24
55
|
},
|
|
25
56
|
},
|
|
26
57
|
async run({ $ }) {
|
|
27
|
-
const
|
|
28
|
-
|
|
58
|
+
const caseId = assertSalesforceId(this.caseId, "Case ID");
|
|
59
|
+
|
|
60
|
+
const allFields = (await this.salesforce
|
|
61
|
+
.getFieldsForObjectType(constants.OBJECT_TYPE.CASE_COMMENT))
|
|
62
|
+
.map(({ name }) => name);
|
|
63
|
+
const fields = buildFieldList(this.fields, allFields);
|
|
64
|
+
|
|
65
|
+
let query = `SELECT ${fields.join(", ")} FROM ${constants.OBJECT_TYPE.CASE_COMMENT}`
|
|
66
|
+
+ ` WHERE ParentId = '${caseId}' ORDER BY CreatedDate DESC, Id DESC`;
|
|
67
|
+
if (this.limit) {
|
|
68
|
+
query += ` LIMIT ${this.limit}`;
|
|
69
|
+
}
|
|
29
70
|
|
|
30
|
-
const
|
|
71
|
+
const response = await this.salesforce.query({
|
|
31
72
|
$,
|
|
32
73
|
query,
|
|
33
74
|
});
|
|
34
|
-
|
|
75
|
+
const { records } = response;
|
|
76
|
+
$.export("$summary", `Successfully retrieved ${records.length} comment${records.length === 1
|
|
77
|
+
? ""
|
|
78
|
+
: "s"} for case with ID ${caseId}.${truncationNote(response, records.length)}`);
|
|
35
79
|
return records;
|
|
36
80
|
},
|
|
37
81
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
2
|
+
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
|
+
import {
|
|
5
|
+
assertSalesforceId, escapeSoqlString,
|
|
6
|
+
} from "../../common/soql.mjs";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "salesforce_rest_api-list-case-feed-items",
|
|
10
|
+
name: "List Case Feed Items",
|
|
11
|
+
description: "List the feed (Chatter) entries on a case, newest first."
|
|
12
|
+
+ " Use this to read a case's activity trail - text posts, status changes, logged calls, email events and case comment events - in one call."
|
|
13
|
+
+ " The case feed only exists when feed tracking is enabled for Cases in the Salesforce org, so an org without it returns no records."
|
|
14
|
+
+ " [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_feed.htm)",
|
|
15
|
+
version: "0.0.1",
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
openWorldHint: true,
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
},
|
|
21
|
+
type: "action",
|
|
22
|
+
props: {
|
|
23
|
+
salesforce,
|
|
24
|
+
caseId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
salesforce,
|
|
27
|
+
"recordId",
|
|
28
|
+
() => ({
|
|
29
|
+
objType: constants.OBJECT_TYPE.CASE,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
label: "Case ID",
|
|
33
|
+
description: "The ID of the case to retrieve feed items for (15- or 18-character Salesforce ID, e.g. `5005g00001ABCDeAAI`). Use the **List Cases** action to retrieve case IDs.",
|
|
34
|
+
},
|
|
35
|
+
feedItemType: {
|
|
36
|
+
type: "string",
|
|
37
|
+
label: "Feed Item Type",
|
|
38
|
+
description: "Return only feed items of this type. By default, feed items of all types are returned.",
|
|
39
|
+
options: constants.CASE_FEED_ITEM_TYPES,
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
42
|
+
limit: {
|
|
43
|
+
type: "integer",
|
|
44
|
+
label: "Limit",
|
|
45
|
+
description: "The maximum number of feed items to return. Valid values are integers from 1 through 1000. Default is 100.",
|
|
46
|
+
default: constants.DEFAULT_LIMIT,
|
|
47
|
+
min: 1,
|
|
48
|
+
max: constants.MAX_LIMIT,
|
|
49
|
+
optional: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
async run({ $ }) {
|
|
53
|
+
const caseId = assertSalesforceId(this.caseId, "Case ID");
|
|
54
|
+
|
|
55
|
+
const fields = (await this.salesforce.getFieldsForObjectType(constants.OBJECT_TYPE.CASE_FEED))
|
|
56
|
+
.map(({ name }) => name);
|
|
57
|
+
|
|
58
|
+
let query = `SELECT ${fields.join(", ")} FROM ${constants.OBJECT_TYPE.CASE_FEED} WHERE ParentId = '${caseId}'`;
|
|
59
|
+
if (this.feedItemType) {
|
|
60
|
+
query += ` AND Type = '${escapeSoqlString(this.feedItemType)}'`;
|
|
61
|
+
}
|
|
62
|
+
query += ` ORDER BY CreatedDate DESC, Id DESC LIMIT ${this.limit || constants.DEFAULT_LIMIT}`;
|
|
63
|
+
|
|
64
|
+
const { records } = await this.salesforce.query({
|
|
65
|
+
$,
|
|
66
|
+
query,
|
|
67
|
+
});
|
|
68
|
+
$.export("$summary", `Successfully retrieved ${records.length} feed item${records.length === 1
|
|
69
|
+
? ""
|
|
70
|
+
: "s"} for case with ID ${this.caseId}`);
|
|
71
|
+
return records;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
2
|
+
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
|
+
import {
|
|
5
|
+
assertSalesforceId, escapeSoqlString, toSoqlDateTimeLiteral,
|
|
6
|
+
} from "../../common/soql.mjs";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "salesforce_rest_api-list-cases",
|
|
10
|
+
name: "List Cases",
|
|
11
|
+
description: "List Salesforce support cases, newest first."
|
|
12
|
+
+ " Use this to find a case and its ID."
|
|
13
|
+
+ " Every filter is optional and they combine with AND - call with no filters to see the most recent cases."
|
|
14
|
+
+ " For example, `Status` `New` with `Limit` `10` returns the ten newest open cases."
|
|
15
|
+
+ " Status values are org-configurable."
|
|
16
|
+
+ " [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_case.htm)",
|
|
17
|
+
version: "0.0.1",
|
|
18
|
+
annotations: {
|
|
19
|
+
destructiveHint: false,
|
|
20
|
+
openWorldHint: true,
|
|
21
|
+
readOnlyHint: true,
|
|
22
|
+
},
|
|
23
|
+
type: "action",
|
|
24
|
+
props: {
|
|
25
|
+
salesforce,
|
|
26
|
+
caseNumber: {
|
|
27
|
+
type: "string",
|
|
28
|
+
label: "Case Number",
|
|
29
|
+
description: "Return only the case with this case number, e.g. `00001024`. This is the human-readable number shown in the Salesforce UI, not the record ID.",
|
|
30
|
+
optional: true,
|
|
31
|
+
},
|
|
32
|
+
subject: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "Subject Contains",
|
|
35
|
+
description: "Return only cases whose subject contains this text (case-insensitive), e.g. `rotor`.",
|
|
36
|
+
optional: true,
|
|
37
|
+
},
|
|
38
|
+
status: {
|
|
39
|
+
type: "string",
|
|
40
|
+
label: "Status",
|
|
41
|
+
description: `Return only cases with this exact status, e.g. \`${constants.CASE_DEFAULT_STATUSES[0]}\`. Org-configurable - use **Describe Object** on \`Case\` to list the valid values.`,
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
accountId: {
|
|
45
|
+
type: "string",
|
|
46
|
+
label: "Account ID",
|
|
47
|
+
description: "Return only cases on this account (15- or 18-character Salesforce ID, e.g. `001P500000dGpZLIA0`). Use **Find Records** on `Account` to look one up.",
|
|
48
|
+
optional: true,
|
|
49
|
+
},
|
|
50
|
+
isClosed: {
|
|
51
|
+
type: "boolean",
|
|
52
|
+
label: "Is Closed",
|
|
53
|
+
description: "Set to `true` to return only closed cases, or `false` for only open ones. Omit to return both.",
|
|
54
|
+
optional: true,
|
|
55
|
+
},
|
|
56
|
+
createdAfter: {
|
|
57
|
+
type: "string",
|
|
58
|
+
label: "Created After",
|
|
59
|
+
description: "Return only cases created on or after this moment. ISO 8601 date (`2026-08-01`) or date-time (`2026-08-01T00:00:00Z`).",
|
|
60
|
+
optional: true,
|
|
61
|
+
},
|
|
62
|
+
fields: {
|
|
63
|
+
propDefinition: [
|
|
64
|
+
salesforce,
|
|
65
|
+
"fieldsToObtain",
|
|
66
|
+
() => ({
|
|
67
|
+
objType: constants.OBJECT_TYPE.CASE,
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
label: "Fields",
|
|
71
|
+
description: `The Case fields to return. Defaults to a compact set: ${constants.CASE_LIST_FIELDS.join(", ")}. \`Id\` is always returned.`,
|
|
72
|
+
optional: true,
|
|
73
|
+
},
|
|
74
|
+
limit: {
|
|
75
|
+
type: "integer",
|
|
76
|
+
label: "Limit",
|
|
77
|
+
description: `The maximum number of cases to return. Valid values are integers from 1 through ${constants.MAX_LIMIT}. Default is ${constants.DEFAULT_LIMIT}.`,
|
|
78
|
+
default: constants.DEFAULT_LIMIT,
|
|
79
|
+
min: 1,
|
|
80
|
+
max: constants.MAX_LIMIT,
|
|
81
|
+
optional: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
async run({ $ }) {
|
|
85
|
+
// Id is always selected: a caller narrowing Fields to save context would
|
|
86
|
+
// otherwise lose the ID that every follow-up case action needs.
|
|
87
|
+
const fields = [
|
|
88
|
+
...new Set([
|
|
89
|
+
"Id",
|
|
90
|
+
...this.fields?.length
|
|
91
|
+
? this.fields
|
|
92
|
+
: constants.CASE_LIST_FIELDS,
|
|
93
|
+
]),
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const conditions = [];
|
|
97
|
+
if (this.caseNumber) {
|
|
98
|
+
conditions.push(`CaseNumber = '${escapeSoqlString(this.caseNumber)}'`);
|
|
99
|
+
}
|
|
100
|
+
if (this.subject) {
|
|
101
|
+
conditions.push(`Subject LIKE '%${escapeSoqlString(this.subject)}%'`);
|
|
102
|
+
}
|
|
103
|
+
if (this.status) {
|
|
104
|
+
conditions.push(`Status = '${escapeSoqlString(this.status)}'`);
|
|
105
|
+
}
|
|
106
|
+
if (this.accountId) {
|
|
107
|
+
conditions.push(`AccountId = '${assertSalesforceId(this.accountId, "Account ID")}'`);
|
|
108
|
+
}
|
|
109
|
+
if (typeof this.isClosed === "boolean") {
|
|
110
|
+
conditions.push(`IsClosed = ${this.isClosed}`);
|
|
111
|
+
}
|
|
112
|
+
if (this.createdAfter) {
|
|
113
|
+
conditions.push(`CreatedDate >= ${toSoqlDateTimeLiteral(this.createdAfter, "Created After")}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let query = `SELECT ${fields.join(", ")} FROM ${constants.OBJECT_TYPE.CASE}`;
|
|
117
|
+
if (conditions.length) {
|
|
118
|
+
query += ` WHERE ${conditions.join(" AND ")}`;
|
|
119
|
+
}
|
|
120
|
+
query += ` ORDER BY CreatedDate DESC, Id DESC LIMIT ${this.limit || constants.DEFAULT_LIMIT}`;
|
|
121
|
+
|
|
122
|
+
const { records } = await this.salesforce.query({
|
|
123
|
+
$,
|
|
124
|
+
query,
|
|
125
|
+
});
|
|
126
|
+
$.export("$summary", `Successfully retrieved ${records.length} case${records.length === 1
|
|
127
|
+
? ""
|
|
128
|
+
: "s"}`);
|
|
129
|
+
return records;
|
|
130
|
+
},
|
|
131
|
+
};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
|
+
import {
|
|
5
|
+
assertSalesforceId, buildFieldList, truncationNote,
|
|
6
|
+
} from "../../common/soql.mjs";
|
|
2
7
|
|
|
3
8
|
export default {
|
|
4
9
|
key: "salesforce_rest_api-list-email-messages",
|
|
5
10
|
name: "List Email Messages",
|
|
6
|
-
description: "
|
|
7
|
-
|
|
11
|
+
description: "List Salesforce email messages, newest first, optionally scoped to one case."
|
|
12
|
+
+ " Returns the full email records including subject and body - use **List Case Feed Items** instead if you only need to know that an email happened."
|
|
13
|
+
+ " Find the case ID with **List Cases** first."
|
|
14
|
+
+ " Omit `Case ID` to list the most recent emails across the org, which can be large - set `Limit`."
|
|
15
|
+
+ " [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailmessage.htm)",
|
|
16
|
+
version: "0.1.0",
|
|
8
17
|
annotations: {
|
|
9
18
|
destructiveHint: false,
|
|
10
19
|
openWorldHint: true,
|
|
@@ -18,26 +27,64 @@ export default {
|
|
|
18
27
|
salesforce,
|
|
19
28
|
"recordId",
|
|
20
29
|
() => ({
|
|
21
|
-
objType:
|
|
30
|
+
objType: constants.OBJECT_TYPE.CASE,
|
|
22
31
|
}),
|
|
23
32
|
],
|
|
24
33
|
label: "Case ID",
|
|
25
|
-
description: "The ID of the case to retrieve email messages for",
|
|
34
|
+
description: "The ID of the case to retrieve email messages for (15- or 18-character Salesforce ID, e.g. `5005g00001ABCDeAAI`). Use the **List Cases** action to retrieve case IDs. Omit to list emails across all records.",
|
|
35
|
+
optional: true,
|
|
36
|
+
},
|
|
37
|
+
fields: {
|
|
38
|
+
propDefinition: [
|
|
39
|
+
salesforce,
|
|
40
|
+
"fieldsToObtain",
|
|
41
|
+
() => ({
|
|
42
|
+
objType: constants.OBJECT_TYPE.EMAIL_MESSAGE,
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
label: "Fields",
|
|
46
|
+
description: "The EmailMessage fields to return. Defaults to every field on the object, which includes the full message body. `Id` is always returned.",
|
|
47
|
+
optional: true,
|
|
48
|
+
},
|
|
49
|
+
limit: {
|
|
50
|
+
type: "integer",
|
|
51
|
+
label: "Limit",
|
|
52
|
+
description: `The maximum number of email messages to return. Valid values are integers from 1 through ${constants.MAX_LIMIT}. Omit to return every message Salesforce sends in one batch.`,
|
|
53
|
+
min: 1,
|
|
54
|
+
max: constants.MAX_LIMIT,
|
|
26
55
|
optional: true,
|
|
27
56
|
},
|
|
28
57
|
},
|
|
29
58
|
async run({ $ }) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
59
|
+
const caseId = this.caseId
|
|
60
|
+
? assertSalesforceId(this.caseId, "Case ID")
|
|
61
|
+
: null;
|
|
62
|
+
|
|
63
|
+
const allFields = (await this.salesforce
|
|
64
|
+
.getFieldsForObjectType(constants.OBJECT_TYPE.EMAIL_MESSAGE))
|
|
65
|
+
.map(({ name }) => name);
|
|
66
|
+
const fields = buildFieldList(this.fields, allFields);
|
|
67
|
+
|
|
68
|
+
let query = `SELECT ${fields.join(", ")} FROM ${constants.OBJECT_TYPE.EMAIL_MESSAGE}`;
|
|
69
|
+
if (caseId) {
|
|
70
|
+
query += ` WHERE RelatedToId = '${caseId}'`;
|
|
71
|
+
}
|
|
72
|
+
query += " ORDER BY CreatedDate DESC, Id DESC";
|
|
73
|
+
if (this.limit) {
|
|
74
|
+
query += ` LIMIT ${this.limit}`;
|
|
34
75
|
}
|
|
35
76
|
|
|
36
|
-
const
|
|
77
|
+
const response = await this.salesforce.query({
|
|
37
78
|
$,
|
|
38
79
|
query,
|
|
39
80
|
});
|
|
40
|
-
|
|
81
|
+
const { records } = response;
|
|
82
|
+
const scope = caseId
|
|
83
|
+
? ` for case with ID ${caseId}`
|
|
84
|
+
: "";
|
|
85
|
+
$.export("$summary", `Successfully retrieved ${records.length} email message${records.length === 1
|
|
86
|
+
? ""
|
|
87
|
+
: "s"}${scope}.${truncationNote(response, records.length)}`);
|
|
41
88
|
return records;
|
|
42
89
|
},
|
|
43
90
|
};
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import salesforce from "../../salesforce_rest_api.app.mjs";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
|
+
import {
|
|
5
|
+
buildFieldList, truncationNote,
|
|
6
|
+
} from "../../common/soql.mjs";
|
|
2
7
|
|
|
3
8
|
export default {
|
|
4
9
|
key: "salesforce_rest_api-list-email-templates",
|
|
5
10
|
name: "List Email Templates",
|
|
6
|
-
description: "
|
|
7
|
-
|
|
11
|
+
description: "List Salesforce email templates, newest first."
|
|
12
|
+
+ " Use this to find a template and its ID before sending with **Send Email**, or before editing with **Update Email Template**."
|
|
13
|
+
+ " For example, run with `Limit` `50`, then pass the `Id` of the template you want to **Send Email**."
|
|
14
|
+
+ " [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailtemplate.htm)",
|
|
15
|
+
version: "0.1.0",
|
|
8
16
|
annotations: {
|
|
9
17
|
destructiveHint: false,
|
|
10
18
|
openWorldHint: true,
|
|
@@ -13,16 +21,47 @@ export default {
|
|
|
13
21
|
type: "action",
|
|
14
22
|
props: {
|
|
15
23
|
salesforce,
|
|
24
|
+
fields: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
salesforce,
|
|
27
|
+
"fieldsToObtain",
|
|
28
|
+
() => ({
|
|
29
|
+
objType: constants.OBJECT_TYPE.EMAIL_TEMPLATE,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
label: "Fields",
|
|
33
|
+
description: "The EmailTemplate fields to return. Defaults to every field on the object, which includes the full template body. `Id` is always returned.",
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
limit: {
|
|
37
|
+
type: "integer",
|
|
38
|
+
label: "Limit",
|
|
39
|
+
description: `The maximum number of templates to return. Valid values are integers from 1 through ${constants.MAX_LIMIT}. Omit to return every template Salesforce sends in one batch.`,
|
|
40
|
+
min: 1,
|
|
41
|
+
max: constants.MAX_LIMIT,
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
16
44
|
},
|
|
17
45
|
async run({ $ }) {
|
|
18
|
-
const
|
|
19
|
-
|
|
46
|
+
const allFields = (await this.salesforce
|
|
47
|
+
.getFieldsForObjectType(constants.OBJECT_TYPE.EMAIL_TEMPLATE))
|
|
48
|
+
.map(({ name }) => name);
|
|
49
|
+
const fields = buildFieldList(this.fields, allFields);
|
|
20
50
|
|
|
21
|
-
|
|
51
|
+
let query = `SELECT ${fields.join(", ")} FROM ${constants.OBJECT_TYPE.EMAIL_TEMPLATE}`
|
|
52
|
+
+ " ORDER BY CreatedDate DESC, Id DESC";
|
|
53
|
+
if (this.limit) {
|
|
54
|
+
query += ` LIMIT ${this.limit}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const response = await this.salesforce.query({
|
|
22
58
|
$,
|
|
23
59
|
query,
|
|
24
60
|
});
|
|
25
|
-
|
|
61
|
+
const { records } = response;
|
|
62
|
+
$.export("$summary", `Successfully retrieved ${records.length} email template${records.length === 1
|
|
63
|
+
? ""
|
|
64
|
+
: "s"}.${truncationNote(response, records.length)}`);
|
|
26
65
|
return records;
|
|
27
66
|
},
|
|
28
67
|
};
|