Creates a File Activity record for a file — a log entry S-Drive uses to track who did what with a file (uploaded it, downloaded it, generated a link for it, and so on). Requires file activities to be configured on the S-Drive Configuration tab first.
How to call this method
global static void createFileActivity(String fileId, String activityType, String prefix, String objectName, String additionalDetails)
global static void createFileActivity(List<String> fileIds, String activityType, String prefix, String objectName, String additionalDetails)
Two overloads: one for a single file, one for recording the same activity across multiple files at once.
Parameters
|
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
|
Yes (single-file overload) |
Id of the file to record activity for. |
|
|
|
Yes (multi-file overload) |
Ids of the files to record activity for. |
|
|
|
Yes |
The type of activity being recorded — e.g. upload, new version, or generating a link. |
|
|
|
Yes |
Prefix of the file object, e.g. |
|
|
|
Yes |
Name of the file object the file belongs to, e.g. |
|
|
|
No |
Extra free-text detail to store on the activity record. |
Return value
Doesn't return anything. Throws an SDriveException if fileId/fileIds is empty, or if the File Activity record fails to insert.
Custom objects need a relationship set up first
For a custom file object, you need a lookup relationship on the File Activity object pointing to that file object before this will work: Setup → Objects → File Activity → Custom Fields & Relationships → New → Lookup Relationship, selecting your file object as the related object.
Example
cg.SDriveTools.createFileActivity(fileId, 'Upload', 'cg__', 'AccountFile__c', '');