Automations Overview
You can use DriveMate functionalitys to support your business process automation in Salesforce. The application provide you with multiple Apex Actions and Flow Components which you can use in your flows or Apex code.
DriveMate Apex Actions
Use the below apex actions to automate your Google Drive file management via flows or Apex code.
Copy File
Action Name
Copy File
Description
Create a copy of a Google Drive file (document, spreadsheet, presentation, etc.) in the specified folder. The copy includes all content - for example, copying a spreadsheet duplicates all sheets, data, formatting, formulas, and charts.
Input parameters:
- File ID (required): ID of the Google Drive file to copy.
- Destination Folder ID (optional): ID of the folder where the copy will be placed. If not specified, the copy is created in the same location as the original.
- New File Name (optional): Name for the copied file. If not specified, defaults to "Copy of [original name]".
Output:
- File ID: ID of the newly created file copy.
- File URL: Web URL to open the copied file.
Apex Code Sample
List<GDCopyFileInvocable.CopyFilePayload> payloads = new List<GDCopyFileInvocable.CopyFilePayload>();
GDCopyFileInvocable.CopyFilePayload payload = new GDCopyFileInvocable.CopyFilePayload();
payload.fileId = '<File ID>';
payload.destinationFolderId = '<Destination Folder ID>';
payload.newFileName = 'My Spreadsheet Copy';
payloads.add(payload);
List<GDCopyFileInvocable.CopyFileResponse> responses = GDCopyFileInvocable.copyFile(payloads);
String copiedFileId = responses[0].fileId;
String copiedFileUrl = responses[0].fileUrl;
Delete Drive Item
Action Name
Delete Drive Item
Description
Delete a Google Drive file or folder. By default, the item is moved to trash (recoverable from Google Drive). Enable the "Permanently Delete" option to remove the item irrecoverably.
Deleting a folder also affects all its contents. Use the "Permanently Delete" option with caution - this action cannot be undone.
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder to delete.
- Permanently Delete (optional): When enabled, the item is permanently deleted instead of moved to trash. Default:
false(move to trash).
Output
None
Apex Code Sample
List<GDDeleteDriveItemInvocable.DeleteDriveItemPayload> payloads = new List<GDDeleteDriveItemInvocable.DeleteDriveItemPayload>();
GDDeleteDriveItemInvocable.DeleteDriveItemPayload payload = new GDDeleteDriveItemInvocable.DeleteDriveItemPayload();
payload.driveItemId = '<Drive Item ID>';
payload.permanentlyDelete = false;
payloads.add(payload);
GDDeleteDriveItemInvocable.deleteDriveItem(payloads);
Delete Drive Item (Async)
Action Name
Delete Drive Item (Async)
Description
Asynchronous equivalent of Delete Drive Item. Enqueues a background job so the calling Flow does not consume a callout. This is particularly useful in after-delete record-triggered flows, where the asynchronous flow path is not available and the synchronous path cannot make callouts.
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder to delete.
- Permanently Delete (optional): When enabled, the item is permanently deleted instead of moved to trash. Default:
false(move to trash).
Output
None
Apex Code Sample
List<GDDeleteDriveItemInvocable.DeleteDriveItemPayload> payloads = new List<GDDeleteDriveItemInvocable.DeleteDriveItemPayload>();
GDDeleteDriveItemInvocable.DeleteDriveItemPayload payload = new GDDeleteDriveItemInvocable.DeleteDriveItemPayload();
payload.driveItemId = '<Drive Item ID>';
payload.permanentlyDelete = false;
payloads.add(payload);
GDDeleteDriveItemInvocableAsync.deleteDriveItem(payloads);
DriveMate Google Drive Folder Component Refresh
Action Name
Refresh DriveMate Google Drive Component
Description
Refresh the DriveMate Google Drive Folder component on the record page to reflect latest changes on the folder that were submitted through non-UI automations.
E.g. if you auto create a folder for your record using a flow, add this action at end of the flow to refresh the component on the record page.
Input parameters:
- Related Record ID: ID of the record related to the folder. The DriveMate Google Drive component will be refreshed on that record's detail page.
Output
None
Apex Code Sample
List<GDRefreshDriveInvocable.RefreshDrivePayload> payloads = new List<GDRefreshDriveInvocable.RefreshDrivePayload>();
GDRefreshDriveInvocable.RefreshDrivePayload payload = new GDRefreshDriveInvocable.RefreshDrivePayload();
payload.relatedRecordId = '<Related Record ID>';
payloads.add(payload);
GDRefreshDriveInvocable.refreshDrive(payloads);
File Search
Action Name
Search Files by Name - Simple Response Structure
Description
Search files in Google Drive by name.
Input parameters:
- Search Term: search term to use in the search.
- Parent Folder ID: ID of the parent folder in Google Drive where the search will be conducted. If not specified, the search will be done in the root of Google Drive.
Output:
-
Matching Files: list of matching files. Each file is represented by a
GDFileModelobject with the following properties:{
"kind": String,
"id": String,
"name": String,
"mimeType": String,
"description": String,
"starred": Boolean,
"trashed": Boolean,
"explicitlyTrashed": Boolean,
"trashedTime": Datetime,
"version": String,
"webContentLink": String,
"webViewLink": String,
"iconLink": String,
"createdTime": Datetime,
"modifiedTime": Datetime,
"teamDriveId": String,
"shared": Boolean,
"originalFilename": String,
"fullFileExtension": String,
"fileExtension": String,
"size": String
}Note:
GDFileModelproperties correspond to the File object properties from the Google Drive API.
Apex Code Sample
List<GDSearchFileSimpleStructureInvocable.SearchPayload> payloads = new List<GDSearchFileSimpleStructureInvocable.SearchPayload>();
GDSearchFileSimpleStructureInvocable.SearchPayload payload = new GDSearchFileSimpleStructureInvocable.SearchPayload();
payload.searchTerm = '<Search Term>';
payload.parentFolderId = '<Parent Folder ID>';
payloads.add(payload);
List<GDSearchFileSimpleStructureInvocable.SearchResponse> responses = GDSearchFileSimpleStructureInvocable.searchFiles(payloads);
List<GDFileModel> resultFiles = responses[0].files;
Folder Creation
Action Name
Create folder - Simple Response Structure
Description
Create a new folder in Google Drive.
Input parameters:
- Folder Name: name of the folder to create.
- Parent Folder ID: ID of the parent folder in Google Drive where the new subfolder will be created. If not specified, it will be created in the root of Google Drive. To check the ID of a folder, open it in Google Drive - the ID is the last part of the URL after "/folders/".
- Folder Description: optional description of the newly created folder.
Output:
- Folder ID: ID of the newly created folder.
Apex Code Sample
List<GDCreateFolderSimpleStructureInvocable.CreateFolderPayload> payloads = new List<GDCreateFolderSimpleStructureInvocable.CreateFolderPayload>();
GDCreateFolderSimpleStructureInvocable.CreateFolderPayload payload = new GDCreateFolderSimpleStructureInvocable.CreateFolderPayload();
payload.folderName = '<Folder Name>';
payload.description = '<Description>';
payload.parentFolderId = '<Parent Folder ID>';
payloads.add(payload);
List<GDCreateFolderSimpleStructureInvocable.CreateFolderResponse> responses = GDCreateFolderSimpleStructureInvocable.createFolder(payloads);
String resultFolderId = responses[0].folderId;
Note: To see a practical example of using this action in a flow to autocreate folders for new records, please refer to the Automatic Folder Assignment article.
Folder Search
Action Name
Search Folders by Name - Simple Response Structure
Description
Search folders in Google Drive by name.
Input parameters:
- Search Term: search term to use in the search.
- Parent Folder ID: ID of the parent folder in Google Drive where the search will be conducted. If not specified, the search will be done in the root of Google Drive.
Output:
-
Matching Folders: list of matching folders. Each folder is represented by a
GDFileModelobject with the following properties:{
"kind": String,
"id": String,
"name": String,
"mimeType": String,
"description": String,
"starred": Boolean,
"trashed": Boolean,
"explicitlyTrashed": Boolean,
"trashedTime": Datetime,
"version": String,
"webContentLink": String,
"webViewLink": String,
"iconLink": String,
"createdTime": Datetime,
"modifiedTime": Datetime,
"teamDriveId": String,
"shared": Boolean,
"originalFilename": String,
"fullFileExtension": String,
"fileExtension": String,
"size": String
}Note:
GDFileModelproperties correspond to the File object properties from the Google Drive API.
Apex Code Sample
List<GDSearchFolderSimpleStructureInvocable.SearchPayload> payloads = new List<GDSearchFolderSimpleStructureInvocable.SearchPayload>();
GDSearchFolderSimpleStructureInvocable.SearchPayload payload = new GDSearchFolderSimpleStructureInvocable.SearchPayload();
payload.searchTerm = '<Search Term>';
payload.parentFolderId = '<Parent Folder ID>';
payloads.add(payload);
List<GDSearchFolderSimpleStructureInvocable.SearchResponse> responses = GDSearchFolderSimpleStructureInvocable.searchFolders(payloads);
List<GDFileModel> resultFolders = responses[0].folders;
Move Drive Item
Action Name
Move File or Folder
Description
Move a Google Drive file or folder to a different parent folder. If the source folder is not specified, DriveMate automatically detects the current parent (this uses one additional API call per item).
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder to move.
- Destination Folder ID (required): ID of the folder to move the item into.
- Source Folder ID (optional): The current parent folder ID. If left empty, the current parent is detected automatically.
Output
None
Apex Code Sample
List<GDMoveDriveItemInvocable.MoveDriveItemPayload> payloads = new List<GDMoveDriveItemInvocable.MoveDriveItemPayload>();
GDMoveDriveItemInvocable.MoveDriveItemPayload payload = new GDMoveDriveItemInvocable.MoveDriveItemPayload();
payload.driveItemId = '<Drive Item ID>';
payload.destinationFolderId = '<Destination Folder ID>';
payload.sourceFolderId = '<Source Folder ID>'; // optional
payloads.add(payload);
GDMoveDriveItemInvocable.move(payloads);
Update Drive Item
Action Name
Update Drive Item
Description
Update the metadata of a Google Drive file or folder. Only the fields you provide are changed - fields left empty remain as they are. At least one field must be specified.
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder to update.
- Name (optional): New name for the file or folder. Leave empty to keep the current name.
- Description (optional): New description for the file or folder. Leave empty to keep the current description.
- Starred (optional): Set to
trueto star the item orfalseto unstar it. Leave empty to keep the current value.
Output
None
Apex Code Sample
List<GDUpdateDriveItemInvocable.UpdateDriveItemPayload> payloads = new List<GDUpdateDriveItemInvocable.UpdateDriveItemPayload>();
GDUpdateDriveItemInvocable.UpdateDriveItemPayload payload = new GDUpdateDriveItemInvocable.UpdateDriveItemPayload();
payload.driveItemId = '<Drive Item ID>';
payload.name = 'New Folder Name';
payload.description = 'Updated description';
payload.starred = true;
payloads.add(payload);
GDUpdateDriveItemInvocable.updateDriveItem(payloads);
Upload File
Action Name
Upload a file - Simple Response Structure
Description
Upload a Salesforce file to Google Drive based on the ContentVersion record.
Note: The maximum Salesforce file size supported is 33MB. Files under 5MB are uploaded synchronously, while files between 5MB and 33MB are uploaded asynchronously.
If you want to upload files without any size limit, use the client-side Upload Component for Screen Flows or the upload functionality of the DriveMate Google Folder component.
Input parameters:
- Content Version ID: ID of the ContentVersion file record to upload.
- Description: optional description of the file created in Google Drive.
- File Name: optional name of the file. By default, the file name will be taken from the ContentVersion record.
- Parent Folder ID: ID of the parent folder in Google Drive where the new file will be created. If not specified, it will be created in the root of Google Drive.
- Delete File After Upload: optional flag to delete the file after upload. Set to
falseby default.
Output:
-
Created Google Drive File ID: ID of the newly uploaded file. This is present only if the file size does not exceed 5MB. Otherwise, it is uploaded asynchronously.
-
Upload Status: status of the upload. Possible values:
Completed- File with size less than 5MB was uploaded successfully;SubmittedAsynchronously- File with size between 5MB and 33MB was submitted for asynchronous upload;Error- Error occurred during upload.
-
Error Message: error message if an error occurred during upload.
Apex Code Sample
List<GDCreateFileSimpleStructureInvocable.CreateFilePayload> payloads = new List<GDCreateFileSimpleStructureInvocable.CreateFilePayload>();
GDCreateFileSimpleStructureInvocable.CreateFilePayload payload = new GDCreateFileSimpleStructureInvocable.CreateFilePayload();
payload.contentVersionId = '<Content Version ID>';
payload.description = '<Description>';
payload.fileName = '<File Name>';
payload.parentFolderId = '<Parent Folder ID>';
payload.deleteFileAfterUpload = false;
payloads.add(payload);
List<GDCreateFileSimpleStructureInvocable.CreateFileResult> responses = GDCreateFileSimpleStructureInvocable.uploadFile(payloads);
String resultFileId = responses[0].id;
String resultUploadStatus = responses[0].status;
String resultErrorMessage = responses[0].error;
DriveMate Screen Flow Components
Use the below components in your Salesforce Screen Flows.
File Upload
Component Name
DriveMate - Google Drive Upload
Description
Upload a file to Google Drive without any size limit.
Input Attributes:
- Folder ID: ID of the parent folder in Google Drive where the new file will be created. If not specified, it will be created in the root of Google Drive.
- List of Accepted File Extensions: comma-separated list of file extensions that will be accepted. e.g.
png,pdf. - Max number of uploaded files at once: maximum number of files that can be uploaded at once.
- Event Dispatched After Upload: You can specify an event that will be dispatched after the file upload is complete - e.g. to automatically finish the flow or go to the next screen. Possible values are:
CloseActionScreen(Closes a Quick Action),FlowNavigationBack,FlowNavigationNext,FlowNavigationPause,FlowNavigationFinish. - Upload Button Label: label displayed on the upload button.
- Drop Zone Label: label displayed on the drop zone.
- Upload Form Label: label displayed above the upload button.
- Container Width Mode: determines whether the component takes all available space or only the space needed for the content. Possible values are:
full(default),content. - Component Alignment: alignment of the component. Possible values are:
left,center,right.
Output:
None
Note: To see a practical example of using this component, please refer to the File Upload Component for Screen Flows article.
File/Folder Navigation (Redirect)
Component Name
Navigate to Drive Element
Description
Redirect to a Google Drive file or folder.
Input Attributes:
- File/Folder ID: ID of the file or folder to navigate to. Mandatory only if the GDrive File/Folder URL parameter is empty.
- File/Folder URL: URL of the file or folder to navigate to. Mandatory only if the File/Folder ID parameter is empty.