Skip to content

Commit 256d87b

Browse files
committed
[ACTION] Salesforce - Content Note action
1 parent 6b2a035 commit 256d87b

File tree

23 files changed

+203
-24
lines changed

23 files changed

+203
-24
lines changed

components/salesforce_rest_api/actions/common/base-create-update.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function getProps({
1414
objType,
1515
createOrUpdate = "create",
1616
docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_concepts.htm",
17+
showDocsInfo = true,
1718
showDateInfo = false,
1819
}) {
1920
let { initialProps } = objType;
@@ -34,6 +35,13 @@ export function getProps({
3435

3536
return {
3637
salesforce,
38+
...showDocsInfo && {
39+
docsInfo: {
40+
type: "alert",
41+
alertType: "info",
42+
content: `[See the documentation](${docsLink}) for more information on available fields.`,
43+
},
44+
},
3745
...showDateInfo && {
3846
dateInfo: {
3947
type: "alert",
@@ -45,11 +53,6 @@ export function getProps({
4553
? "createProps"
4654
: "updateProps"],
4755
...initialProps,
48-
docsInfo: {
49-
type: "alert",
50-
alertType: "info",
51-
content: `[See the documentation](${docsLink}) for more information on available fields.`,
52-
},
5356
useAdvancedProps: {
5457
propDefinition: [
5558
salesforce,

components/salesforce_rest_api/actions/create-account/create-account.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "salesforce_rest_api-create-account",
99
name: "Create Account",
1010
description: `Creates a Salesforce account. [See the documentation](${docsLink})`,
11-
version: "0.3.0",
11+
version: "0.3.1",
1212
type: "action",
1313
methods: {
1414
...common.methods,

components/salesforce_rest_api/actions/create-attachment/create-attachment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
key: "salesforce_rest_api-create-attachment",
1919
name: "Create Attachment",
2020
description: `Creates an Attachment on a parent object. [See the documentation](${docsLink})`,
21-
version: "0.4.0",
21+
version: "0.4.1",
2222
type: "action",
2323
props,
2424
async run({ $ }) {

components/salesforce_rest_api/actions/create-campaign/create-campaign.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "salesforce_rest_api-create-campaign",
99
name: "Create Campaign",
1010
description: `Creates a marketing campaign. [See the documentation](${docsLink})`,
11-
version: "0.3.0",
11+
version: "0.3.1",
1212
type: "action",
1313
methods: {
1414
...common.methods,

components/salesforce_rest_api/actions/create-case/create-case.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "salesforce_rest_api-create-case",
99
name: "Create Case",
1010
description: `Creates a Case, which represents a customer issue or problem. [See the documentation](${docsLink})`,
11-
version: "0.3.0",
11+
version: "0.3.1",
1212
type: "action",
1313
methods: {
1414
...common.methods,

components/salesforce_rest_api/actions/create-casecomment/create-casecomment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default {
1717
key: "salesforce_rest_api-create-casecomment",
1818
name: "Create Case Comment",
1919
description: `Creates a Case Comment on a selected Case. [See the documentation](${docsLink})`,
20-
version: "0.3.0",
20+
version: "0.3.1",
2121
type: "action",
2222
props,
2323
async run({ $ }) {

components/salesforce_rest_api/actions/create-contact/create-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "salesforce_rest_api-create-contact",
99
name: "Create Contact",
1010
description: `Creates a contact. [See the documentation](${docsLink})`,
11-
version: "0.3.0",
11+
version: "0.3.1",
1212
type: "action",
1313
methods: {
1414
...common.methods,
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* eslint-disable no-unused-vars */
2+
import common, { getProps } from "../common/base-create-update.mjs";
3+
import contentNote from "../../common/sobjects/content-note.mjs";
4+
import contentDocumentLink from "../../common/sobjects/content-document-link.mjs";
5+
6+
const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentnote.htm";
7+
8+
const {
9+
useAdvancedProps: contentNoteUseAdvancedProps,
10+
...contentNoteProps
11+
} = getProps({
12+
objType: contentNote,
13+
docsLink,
14+
});
15+
16+
const {
17+
useAdvancedProps: contentDocumentLinkUseAdvancedProps,
18+
...contentDocumentLinkProps
19+
} = getProps({
20+
objType: contentDocumentLink,
21+
docsLink,
22+
showDocsInfo: false,
23+
});
24+
25+
export default {
26+
...common,
27+
key: "salesforce_rest_api-create-content-note",
28+
name: "Create Content Note",
29+
description: `Creates a content note. [See the documentation](${docsLink}) and [Set Up Notes](https://help.salesforce.com/s/articleView?id=sales.notes_admin_setup.htm&type=5).`,
30+
version: "0.0.1",
31+
type: "action",
32+
props: {
33+
...contentNoteProps,
34+
...contentDocumentLinkProps,
35+
},
36+
methods: {
37+
...common.methods,
38+
escapeHtml4(unsafe) {
39+
return unsafe
40+
.replace(/&/g, "&")
41+
.replace(/</g, "&lt;")
42+
.replace(/>/g, "&gt;")
43+
.replace(/"/g, "&quot;")
44+
.replace(/'/g, "&#039;");
45+
},
46+
},
47+
async run({ $ }) {
48+
const {
49+
salesforce,
50+
escapeHtml4,
51+
Title,
52+
Content,
53+
OwnerId,
54+
LinkedEntityId,
55+
ShareType,
56+
Visibility,
57+
} = this;
58+
59+
const contentNoteResponse = await salesforce.createRecord("ContentNote", {
60+
$,
61+
data: {
62+
Title,
63+
Content: Buffer.from(escapeHtml4(Content)).toString("base64"),
64+
OwnerId: OwnerId,
65+
},
66+
});
67+
68+
if (!LinkedEntityId) {
69+
$.export("$summary", `Successfully created content note with ID \`${contentNoteResponse.id}\`.`);
70+
return {
71+
contentNote: contentNoteResponse,
72+
};
73+
}
74+
75+
const contentDocumentLinkResponse = await salesforce.createRecord("ContentDocumentLink", {
76+
$,
77+
data: {
78+
ContentDocumentId: contentNoteResponse.id,
79+
LinkedEntityId,
80+
ShareType,
81+
Visibility,
82+
},
83+
});
84+
85+
$.export("$summary", `Successfully created content note with ID \`${contentNoteResponse.id}\` and document link with ID \`${contentDocumentLinkResponse.id}\`.`);
86+
return {
87+
contentNote: contentNoteResponse,
88+
contentDocumentLink: contentDocumentLinkResponse,
89+
};
90+
},
91+
};

components/salesforce_rest_api/actions/create-event/create-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
key: "salesforce_rest_api-create-event",
1010
name: "Create Event",
1111
description: `Creates an event. [See the documentation](${docsLink})`,
12-
version: "0.3.0",
12+
version: "0.3.1",
1313
type: "action",
1414
methods: {
1515
...common.methods,

components/salesforce_rest_api/actions/create-lead/create-lead.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "salesforce_rest_api-create-lead",
99
name: "Create Lead",
1010
description: `Creates a lead. [See the documentation](${docsLink})`,
11-
version: "0.3.0",
11+
version: "0.3.1",
1212
type: "action",
1313
methods: {
1414
...common.methods,

0 commit comments

Comments
 (0)