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 Flow and 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;
Share Drive Item
Action Name
Share Drive Item
Description
Grants direct access to a Google Drive file or folder for the specified email addresses. Existing direct access is never reduced - for example, a user with writer access will not be downgraded to reader when this action requests reader access.
These sharing actions affect direct permissions only. Inherited access from a parent folder or shared drive membership is not changed. A user may retain access through inheritance even after direct access is removed with the Update Drive Item Sharing action.
Some roles (such as fileOrganizer and organizer) are only available for certain drive types.
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder.
- Access Role (required): Direct access level to grant:
reader,commenter,writer,fileOrganizer,organizer, orowner. - Recipient Emails (optional): List of email addresses to share with. Provide either this list or Comma-Separated Recipient Emails.
- Comma-Separated Recipient Emails (optional): Email addresses as a comma-separated string. Provide either this or Recipient Emails.
- Send Notification Email (optional): When
true, Google sends an email notification for newly created direct permissions. Defaults totrue. Role updates do not send notifications. Ownership transfers always notify the recipient. - Email Message (optional): Optional message included in the Google notification email when a new direct permission is created.
- Require Target User Confirmation (optional): Applies when Access Role is
owner. Whentrue(default), the recipient must accept ownership in Google Drive - required for Gmail accounts and users outside your Google Workspace organization. Whenfalse, ownership transfers immediately for recipients in the same Google Workspace organization as the authenticated user.
Output
None
Apex Code Sample
List<ShareDriveItemInvocable.ShareDriveItemPayload> payloads = new List<ShareDriveItemInvocable.ShareDriveItemPayload>();
ShareDriveItemInvocable.ShareDriveItemPayload payload = new ShareDriveItemInvocable.ShareDriveItemPayload();
payload.driveItemId = '<Drive Item ID>';
payload.accessRole = 'writer';
payload.recipientEmails = new List<String>{ '[email protected]', '[email protected]' };
payload.sendNotificationEmail = true;
payload.emailMessage = 'Please review this file.';
payloads.add(payload);
ShareDriveItemInvocable.shareDriveItem(payloads);
Update Drive Item Sharing
Action Name
Update Drive Item Sharing
Description
Sets direct access on a Google Drive file or folder to exactly the specified level for each email address, including downgrades. Use remove_access to remove direct access. When no direct permission exists for an email address, remove_access is skipped silently.
These sharing actions affect direct permissions only. Inherited access is not changed.
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder.
- Access Role (required): Direct access level to set:
reader,commenter,writer,fileOrganizer,organizer,owner, orremove_access. - Recipient Emails (optional): List of email addresses to update. Provide either this list or Comma-Separated Recipient Emails.
- Comma-Separated Recipient Emails (optional): Email addresses as a comma-separated string. Provide either this or Recipient Emails.
- Send Notification Email (optional): When
true, Google sends an email notification when a new direct permission is created. Defaults totrue. Updates and removals do not send notifications. Ownership transfers always notify the recipient. - Email Message (optional): Optional message included in the Google notification email when a new direct permission is created.
- Require Target User Confirmation (optional): Applies when Access Role is
owner. Whentrue(default), the recipient must accept ownership in Google Drive. Whenfalse, ownership transfers immediately for recipients in the same Google Workspace organization as the authenticated user.
Output
None
Apex Code Sample
List<UpdateDriveItemSharingInvocable.UpdateDriveItemSharingPayload> payloads = new List<UpdateDriveItemSharingInvocable.UpdateDriveItemSharingPayload>();
UpdateDriveItemSharingInvocable.UpdateDriveItemSharingPayload payload = new UpdateDriveItemSharingInvocable.UpdateDriveItemSharingPayload();
payload.driveItemId = '<Drive Item ID>';
payload.accessRole = 'remove_access';
payload.recipientEmails = new List<String>{ '[email protected]' };
payloads.add(payload);
UpdateDriveItemSharingInvocable.updateDriveItemSharing(payloads);
Get Drive Item Permissions
Action Name
Get Drive Item Permissions
Description
Returns direct user permissions, inherited user permissions, and the current public link sharing settings for a Google Drive file or folder.
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder.
Output:
- Direct Permissions: Direct user permissions on the drive item.
- Inherited Permissions: User permissions inherited from a parent folder or shared drive membership.
- General Access Type: Public link sharing setting:
restrictedoranyone. - General Access Role: Role granted to anyone with the link when General Access Type is
anyone.
Apex Code Sample
List<GetDriveItemPermissionsInvocable.GetDriveItemPermissionsPayload> payloads = new List<GetDriveItemPermissionsInvocable.GetDriveItemPermissionsPayload>();
GetDriveItemPermissionsInvocable.GetDriveItemPermissionsPayload payload = new GetDriveItemPermissionsInvocable.GetDriveItemPermissionsPayload();
payload.driveItemId = '<Drive Item ID>';
payloads.add(payload);
List<GetDriveItemPermissionsInvocable.GetDriveItemPermissionsResponse> responses = GetDriveItemPermissionsInvocable.getDriveItemPermissions(payloads);
List<GetDriveItemPermissionsInvocable.DirectPermissionResult> directPermissions = responses[0].directPermissions;
String generalAccessType = responses[0].generalAccessType;
Update Drive Item General Access
Action Name
Update Drive Item General Access
Description
Sets public link sharing for a Google Drive file or folder. Use restricted to disable anyone-with-the-link access, or anyone to enable link sharing with the specified role.
Input parameters:
- Drive Item ID (required): ID of the Google Drive file or folder.
- General Access Type (required): Public link sharing setting:
restrictedoranyone. - General Access Role (optional): Role for anyone-with-the-link access:
reader,commenter, orwriter. Required when General Access Type isanyone.
Output
None
Apex Code Sample
List<UpdateDriveItemGeneralAccessInvocable.UpdateDriveItemGeneralAccessPayload> payloads = new List<UpdateDriveItemGeneralAccessInvocable.UpdateDriveItemGeneralAccessPayload>();
UpdateDriveItemGeneralAccessInvocable.UpdateDriveItemGeneralAccessPayload payload = new UpdateDriveItemGeneralAccessInvocable.UpdateDriveItemGeneralAccessPayload();
payload.driveItemId = '<Drive Item ID>';
payload.generalAccessType = 'anyone';
payload.generalAccessRole = 'reader';
payloads.add(payload);
UpdateDriveItemGeneralAccessInvocable.updateDriveItemGeneralAccess(payloads);
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.