...
...
Salesforce Files
In order to use the below APIs, you must enable Salesforce Files support within Pulsar. Please see "Enable Salesforce Files" for instructions for doing this.
...
readSFFile
Info |
---|
icon | false |
---|
This API call returns an array containing a dictionary with the ContentVersion object for the ContentDocument or ContentVersion matching the Id specified. Important returned fields: – base64 – base64 encoded file thumbnail data (if ReturnBase64Data is not false and the file is an image) FileURL – local URL to the file
ThumbURL – local URL to the file thumbnail (empty string if file is not an image)
Related Pulsar Settings: |
Code Block |
---|
var request = {
"type" : "readSFFile",
"data" : {
"Id" : "069234567891234", // Required ContentDocument or ContentVersion Id
"ReturnBase64Data" : false, // Optional, default true. If false you will still have access to URL of file
"DownloadVersionData" : true, // Optional, default true. If true and online, Pulsar will attempt to download the file from the server to ensure it has the latest version. If false, it will skip this step and use the data is available locally, if it exists.
}
};
bridge.sendRequest(request, function (responseData) { alert('The File is located here: ' + responseData.data[0].FileURL }); |
Note |
---|
Normal data reads through 'select' API will not contain Base64 file data in the VersionData field unless that field has previously been queried from Salesforce or otherwise populated with Base64 data. panel | title |
---|
queryContent
Info |
---|
|
|
This API call returns an array of dictionaries representing ContentVersion objects matching the specified filter. The filter is specified in sqlite where clause format, and is applied to objects in the ContentVersion table only. For example "(ContentDocumentId= '069234567891234')" will return all ContentVersions where the ContentDocumentId field is set to 069234567891234. This method will return URLs to a cached version of the File, but will not return the file data directly as in readSFFile.
Important returned fields:
FileURL
– local URL to the file
ThumbURL
– local URL to the thumbnail file (empty string if file is not an image)
FilePath
- local relative or absolute path to the file
ThumbPath
- local relative or absolute path to the file
Code Block |
---|
var request = {
"type" : "queryContent",
"data" : {
/* give us all synced files attached to account with Id 001abc012345678ABC */
"filter" : "ContentDocumentId in (SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '001abc012345678ABC')",
"DownloadVersionData" : true, // Optional, default true. If true and online, Pulsar will attempt to download the files from the server to ensure it has the latest version. If false, it will skip this step and use the data is available locally, if it exists.
}
};
bridge.sendRequest(request, function (responseData) { alert('The first File is located here: ' + responseData.data[0].FileURL }); |
Note |
---|
The queryContent API call will NOT return the ContentVersion's Base64 VersionData field or the Base64 data representing the thumbnail. Panel | title |
createSFFile
Info |
---|
|
|
The createSFFile
method allows creation of Salesforce Files directly from Base64 encoded data. The intended parent SObject Id (ParentId), Name, and Body are required arguments. The ContentType of the File may be optionally specified in MIME type format, as in the example below. On success, the response data contains the Id of the created ContentDocument.
Code Block |
---|
var request = {
"type" : "createSFFile",
"data" : {
"ParentId" : "001234567891234", // Required
"Name" : "FileName.jpg", // Required
"Body" : "AABBCCDDEEFF...", // Base64 data -- Required
"ContentType" : "image/jpeg", // Optional -- manual entry of content type
"NetworkId" : "0DB123456789123" // Optional, the NetworkId of the current Experience Cloud site- NOTE: this would be required only for your Salesforce Community Users
}
};
bridge.sendRequest(request, function (responseData) {
if (responseData.type == "createSFFileResponse") {
alert('Created Content Document Id: ' + responseData.data);
}
else {
// error code
}
}); |
createSFFileFromFilePath
Anchor |
---|
| createsffilefromfilepath |
---|
| createsffilefromfilepath |
---|
|
...
title | createSFFileFromFilePath |
---|
|
Info |
---|
|
|
The createSFFileFromFilePath
method allows creation of Salesforce Files directly from valid, accessible, device file paths. The intended File parent SObject Id and FilePath are required arguments. The ContentType of the File may be optionally specified in MIME type format, as in the example below.
Optionally Optionally, you can specify a file name, instead of using the name of the original file. On success, the response data contains the Id of the created ContentDocument.
Code Block |
---|
var request = {
"type" : "createSFFileFromFilePath",
"data" : {
"ParentId" : "001234567891234", // Required
"Name" : "FileName.jpg", // Optional
"ContentType" : "image/jpeg", // Optional -- manual entry of content type
"FilePath" : "/Valid/Path/To/File.Jpg", // Required
"NetworkId" : "0DB123456789123" // Optional, the NetworkId of the current Experience Cloud site- NOTE: this would be required only for your Salesforce Community Users
}
};
bridge.sendRequest(request, function (responseData) {
if (responseData.type == "createSFFileResponse") {
alert('Created ContentDocument Id: ' + responseData.data);
}
}
else {
// error code
}
}); |
createSFFileFromCamera
Anchor |
---|
| createsffilefromcamera |
---|
| createsffilefromcamera |
---|
|
Panel |
---|
title | createSFFileFromCamera |
---|
|
Info |
---|
|
|
The createSFFileFromCamera
method allows creation of Salesforce Files directly from the device's camera. The intended File's parent SObject Id is a required argument. Optionally, you can specify a file name for the File, instead of using the name of the original file. On success, the response data contains the Id of the created ContentDocument.
Code Block |
---|
var request = {
"type" : "createSFFileFromCamera",
"data" : {
"ParentId" : "001234567891234", // Required
"Name" : "FileName.jpg", // Optional
"NetworkId" : "0DB123456789123" // Optional, the NetworkId of the current Experience Cloud site- NOTE: this would be required only for your Salesforce Community Users
}
};
bridge.sendRequest(request, function (responseData) {
if (responseData.type == "createSFFileResponse") {
alert('Created ContentDocumentId: ' + responseData.data);
}
else {
// error code
}
}); Panel |
---|
| title |
---|
deleteSFFile
Info |
---|
icon | false |
---|
The deleteSFFile method allows deletion of Salesforce Files. A list of content document ids is the only required argument. On success, the response type will be 'deleteSFFileResponse'. |
Code Block |
---|
var request = {
"type" : "deleteSFFile",
"data" : {
"documentIdList" : ["069234567891234"] // Required
}
};
bridge.sendRequest(request, function (responseData) {
if (responseData.type == "deleteSFFileResponse") {
alert('delete success');
}
else {
alert('delete error');
}
}); |