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.
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;
Salesforce File Sync to Google Drive
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.