24Files Apex methods
Parameters
The following capitalized items need to be replaced by your specific values when calling the 24Files Apex methods:
RECORD_ID = ID of the record
FOLDER = relative folder to the record folder. Note: in case of anonymous access, you can only upload in the public folder. Hence, leave the FOLDER argument empty ''.
USE_ANONYMOUS_AUTH = set to ‘true’ to use anonymous auth or ‘false’ to use authenticated auth
EMAIL_ADDRESS = email address where results should be sent to
CONTENT_VERSION_ID = Salesforce content version id where the file is stored in
PATH = relative path to the file from the record folder
Note that in case of Anonymous Authentication the PATH is the path relative from the Public Folder. For Authenticated Authentication, this is the path relative from the Record Folder.
Limitations
With APEX, file uploads are limited to a maximum size of 35 MB per file.
The getFileLink APEX method returns a link with an expiration duration that has been set in the 24Files Settings page in the 24Files Manager app.
Create Single Folder
sfy_office365.AddFolderGlobalMethod.FolderRequest folderRequest = new sfy_office365.AddFolderGlobalMethod.FolderRequest(RECORD_ID, FOLDER, USE_ANONYMOUS_AUTH);
sfy_office365.CreateFoldersGlobalMethod.createFolder(folderRequest, EMAIL_ADDRESS);
Create Multiple Folders
sfy_office365.CreateFoldersGlobalMethod.createFolders(new List<sfy_office365.AddFolderGlobalMethod.FolderRequest>(), EMAIL_ADDRESS);
Create Folder Structure
List<sfy_office365.GenerateFolderStructureGlobalMethod.FolderStructureRequest> generateFolderStructures = new List<sfy_office365.GenerateFolderStructureGlobalMethod.FolderStructureRequest>{new sfy_office365.GenerateFolderStructureGlobalMethod.FolderStructureRequest(RECORD_ID, USE_ANONYMOUS_AUTH, EMAIL_ADDRESS)};
sfy_office365.GenerateFolderStructureGlobalMethod.generateFolderStructure(generateFolderStructures);
Upload File
sfy_office365.AddFileGlobalMethod.FileRequest uploadFile = new sfy_office365.AddFileGlobalMethod.FileRequest(RECORD_ID, FOLDER, CONTENT_VERSION_ID, USE_ANONYMOUS_AUTH);
sfy_office365.UploadFilesGlobalMethod.uploadFile(uploadFile, EMAIL_ADDRESS);
Upload Files
sfy_office365.UploadFilesGlobalMethod.uploadFiles(new List<sfy_office365.AddFileGlobalMethod.FileRequest>(), EMAIL_ADDRESS);
Get File Link
List<sfy_office365.GetFileLinksGlobalMethod.FileLinkRequest> fileLinkRequests = new List<sfy_office365.GetFileLinksGlobalMethod.FileLinkRequest>{new sfy_office365.GetFileLinksGlobalMethod.FileLinkRequest(RECORD_ID, PATH, USE_ANONYMOUS_AUTH)};
sfy_office365.GetFileLinksGlobalMethod.getFileLink(fileLinkRequests);
Metadata Sync
24Files allows you to sync Salesforce fields to SharePoint metadata at the time when a new record is created. Use this Apex method to enable a sync at other times, e.g. when records fields are updated.
X24FilesMetadataSync.metadataSync(List<String> recordIds);
Rename Record Folder
Use this Apex method to rename the record folder in SharePoint, e.g. triggered by a change of the record folder name in Salesforce.
X24FilesRenameRecordFolder.renameRecordFolders(List<String> recordIds);