-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[ACTION] Salesforce - Content Note action #14914
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
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
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
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
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
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
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
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
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
91 changes: 91 additions & 0 deletions
91
components/salesforce_rest_api/actions/create-content-note/create-content-note.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,91 @@ | ||
/* eslint-disable no-unused-vars */ | ||
import common, { getProps } from "../common/base-create-update.mjs"; | ||
import contentNote from "../../common/sobjects/content-note.mjs"; | ||
import contentDocumentLink from "../../common/sobjects/content-document-link.mjs"; | ||
|
||
const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentnote.htm"; | ||
|
||
const { | ||
useAdvancedProps: contentNoteUseAdvancedProps, | ||
...contentNoteProps | ||
} = getProps({ | ||
objType: contentNote, | ||
docsLink, | ||
}); | ||
|
||
const { | ||
useAdvancedProps: contentDocumentLinkUseAdvancedProps, | ||
...contentDocumentLinkProps | ||
} = getProps({ | ||
objType: contentDocumentLink, | ||
docsLink, | ||
showDocsInfo: false, | ||
}); | ||
|
||
export default { | ||
...common, | ||
key: "salesforce_rest_api-create-content-note", | ||
name: "Create Content Note", | ||
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).`, | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
...contentNoteProps, | ||
...contentDocumentLinkProps, | ||
}, | ||
methods: { | ||
...common.methods, | ||
escapeHtml4(unsafe) { | ||
return unsafe | ||
.replace(/&/g, "&") | ||
.replace(/</g, "<") | ||
.replace(/>/g, ">") | ||
.replace(/"/g, """) | ||
.replace(/'/g, "'"); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
salesforce, | ||
escapeHtml4, | ||
Title, | ||
Content, | ||
OwnerId, | ||
LinkedEntityId, | ||
ShareType, | ||
Visibility, | ||
} = this; | ||
|
||
const contentNoteResponse = await salesforce.createRecord("ContentNote", { | ||
$, | ||
data: { | ||
Title, | ||
Content: Buffer.from(escapeHtml4(Content)).toString("base64"), | ||
OwnerId: OwnerId, | ||
}, | ||
}); | ||
|
||
if (!LinkedEntityId) { | ||
$.export("$summary", `Successfully created content note with ID \`${contentNoteResponse.id}\`.`); | ||
return { | ||
contentNote: contentNoteResponse, | ||
}; | ||
} | ||
|
||
const contentDocumentLinkResponse = await salesforce.createRecord("ContentDocumentLink", { | ||
$, | ||
data: { | ||
ContentDocumentId: contentNoteResponse.id, | ||
LinkedEntityId, | ||
ShareType, | ||
Visibility, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created content note with ID \`${contentNoteResponse.id}\` and document link with ID \`${contentDocumentLinkResponse.id}\`.`); | ||
return { | ||
contentNote: contentNoteResponse, | ||
contentDocumentLink: contentDocumentLinkResponse, | ||
}; | ||
}, | ||
}; |
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
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
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
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
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
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
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
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
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
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
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
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
51 changes: 51 additions & 0 deletions
51
components/salesforce_rest_api/common/sobjects/content-document-link.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,51 @@ | ||
export default { | ||
initialProps: { | ||
LinkedEntityId: { | ||
type: "string", | ||
label: "Linked Entity ID", | ||
description: "ID of the linked object. Can include Chatter users, groups, records (any that support Chatter feed tracking including custom objects), and Salesforce CRM Content libraries.", | ||
optional: true, | ||
}, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ShareType: { | ||
type: "string", | ||
label: "Share Type", | ||
description: "The permission granted to the user of the shared file in a library. This is determined by the permission the user already has in the library.", | ||
optional: true, | ||
default: "I", | ||
options: [ | ||
{ | ||
label: "Viewer Permission", | ||
value: "V", | ||
}, | ||
{ | ||
label: "Collaborator Permission", | ||
value: "C", | ||
}, | ||
{ | ||
label: "Inferred Permission", | ||
value: "I", | ||
}, | ||
], | ||
}, | ||
Visibility: { | ||
type: "string", | ||
label: "Visibility", | ||
description: "Specifies whether this file is available to all users, internal users, or shared users.", | ||
optional: true, | ||
options: [ | ||
{ | ||
label: "All Users", | ||
value: "AllUsers", | ||
}, | ||
{ | ||
label: "Internal Users", | ||
value: "InternalUsers", | ||
}, | ||
{ | ||
label: "Shared Users", | ||
value: "SharedUsers", | ||
}, | ||
], | ||
}, | ||
}, | ||
}; |
34 changes: 34 additions & 0 deletions
34
components/salesforce_rest_api/common/sobjects/content-note.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 { | ||
initialProps: { | ||
OwnerId: { | ||
propDefinition: [ | ||
salesforce, | ||
"recordId", | ||
() => ({ | ||
objType: "User", | ||
nameField: "Name", | ||
}), | ||
], | ||
label: "Owner ID", | ||
description: "ID of the user who owns the note.", | ||
}, | ||
Title: { | ||
type: "string", | ||
label: "Title", | ||
description: "Title of the note.", | ||
}, | ||
Content: { | ||
type: "string", | ||
label: "Content", | ||
description: "The content or body of the note, which can include properly formatted HTML or plain text.", | ||
}, | ||
IsReadOnly: { | ||
type: "boolean", | ||
label: "Read Only", | ||
description: "Indicates whether the note is read only.", | ||
optional: true, | ||
}, | ||
}, | ||
}; |
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
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.