Appiphony
 
  • Products
    • Merge Connect Document Generation
    • eSign Connect Docusign Integration
    • Parse Connect Document Parsing
    • Share Connect SharePoint Integration
    • Drive Connect Google Drive Integration
    • Experience Connect Experience Cloud Add-on
  • Company
  • Resources
    • Documentation Learn about our products
    • Blog Salesforce guides and tutorials
    • Customer Stories How our customers succeed
    • Videos Visit our YouTube channel
    • Company Get to know Appiphony
    • Careers View openings
    • PDO Services Build with Appiphony
    • PDO Customer Portal Access our customer portal
  • Pricing
Product Documentation Contact Us

Can I migrate Google Drive URLs to Drive Connect Default Record Folders?

If you have been storing Google Drive folder URLs on your Salesforce records, we can help you move them with a script. The below script will need to be modified for the Object (red) and any object field or variable references as well as the custom URL field (blue) you would want to run this script on.

 
Map<String,Account> accountsById = new Map<String, Account>([SELECT Id, Name, Google_Drive_Folder__c FROM Account WHERE Google_Drive_Folder__c LIKE '%.google.com%']);
Set<String> recordIds = accountsById.keySet();
Map<String, Map<String, String>> filesByUrl = new Map<String, Map<String, String>>();
Map<String, ContentVersion> cvByUrl = new Map<String, ContentVersion>();
List<ContentDocumentLink> cdlsToInsert = new List<ContentDocumentLink>();
List<String> cvIds = new List<String>();
List<ContentDocumentLink> cdls = [
SELECT Id, LinkedEntityId
FROM ContentDocumentLink
WHERE LinkedEntityId IN :recordIds
AND ContentDocument.LatestPublishedVersion.driveconnect__Default_Record_Folder__c = true
WITH SECURITY_ENFORCED
];
for(ContentDocumentLink cdl : cdls) {
String accountId = cdl.LinkedEntityId;
if(accountsById.containsKey(accountId)) accountsById.remove(accountId);
}
List<Account> accounts = accountsById.values();
if(accounts.size() > 0) {
Integer max = accounts.size() > 100 ? 100 : accounts.size();
for(Integer i = 0; i < max; i++) {
Account account = accounts[i];
filesByUrl.put(account.Google_Drive_Folder__c, new Map<String, String> {
'url' => account.Google_Drive_Folder__c,
'mimeType' => 'application/vnd.google-apps.folder',
'IsDefaultRecordFolder' => 'true',
'name' => account.Name,
'recordId' => account.Id
});
}
for(Map<String, String> file : filesByUrl.values()) {
ContentVersion cv = new ContentVersion(
ContentUrl = file.get('url'),
Title = file.get('name'),
driveconnect__Default_Record_Folder__c = true
);
cvByUrl.put(file.get('url'), cv);
}
insert cvByUrl.values();
for(ContentVersion contentVersion : cvByUrl.values()) {
cvIds.add(contentVersion.Id);
}
for(ContentDocument cd : [SELECT Id, LatestPublishedVersion.ContentUrl FROM ContentDocument WHERE LatestPublishedVersionId IN :cvIds WITH SECURITY_ENFORCED]) {
Map<String, String> file = filesByUrl.get(cd.LatestPublishedVersion.ContentUrl);
cdlsToInsert.add(new ContentDocumentLink(
ContentDocumentId = cd.Id,
LinkedEntityId = file.get('recordId'),
ShareType = 'V'
));
}
insert cdlsToInsert;
}

Once you have made the necessary modifications and have the custom URL fields populated for the desired records you can run the code. This can be done by going to Salesforce Setup > Developer Console > Debug > Open Execute Anonymous Window, pasting the script into the Apex window, and clicking Execute. Once this has been successfully executed you will see default record folders on the Drive Links component.

There is a max limit of 100 records that can be affected per execution which means that you will need to run this script multiple times until the desired number of records are affected. Here is a video demonstration of how to run the script.

Getting Started

  • Introduction
  • Installation & Setup
  • FAQs
    • How do I update Drive Connect?
    • Can I trial Drive Connect?
    • How is Drive Connect used in a sandbox environment?
    • How do I open a support ticket with the Drive Connect team?
    • Can I provide the Drive Connect team with feedback?
    • Why Can't I Preview Files in Safari?
    • How do I sign out of my Google account in Drive Connect?
    • How do I manage Google account access for Drive Connect?
    • How do I grant access to folders in Google Drive?
    • What are the Drive Connect remote sites?
    • How does Drive Connect use Google OAuth 2.0 Scope to access Google APIs?
    • How do I activate Drive Links on mobile devices?
    • Can I migrate Google Drive URLs to Drive Connect Default Record Folders?
    • Why are tabs missing from the Drive Connect app?
    • Can I automatically assign licenses and permissions to new Drive Connect users?
    • What can I do if Licensing & Permissions does not load?
    • What should I do if I encounter "Google picker error – The API developer key is invalid"?
    • What should I do if renaming a custom object does not reflect the correct name in related Object picklists?
    • How do I fix "Managing Drive Connect Payments Error – Remote Site Activation Needed"?
    • Why is "Sign in with Google" not working in Safari?
    • Why isn't my Google profile picture visible in Drive Connect?
    • How to Leave an AppExchange Review for Drive Connect
    • Why are my Schedule-Triggered Flows not working?
    • Issues installing Drive Connect: Dynamic Imports are Not Allowed
    • Why is Document Generation no Longer Supported?
  • Release Notes

Features

  • File Management
    • Linking
    • Viewing
    • Downloading
    • Renaming
    • Unlinking
    • Embedding
    • Sharing & Permissions
    • Saving to Salesforce
    • Uploading to Drive
    • Emailing Files
    • Experience Cloud
  • Folder Management
    • Linking
    • Viewing
    • Renaming
    • Unlinking
    • Sharing & Permissions
    • Content Folders
    • Default Folders
  • Automation
    • Automation Setup
    • Creating Automations
    • Automating File Upload
    • Updating Files
    • Automating Folders
    • Automating Files
    • Destination Locations
    • Decision Trees
    • Publishing Platform Events
    • Updating Folders
  • Document Generation (Legacy)
    • Template Builder Tab
    • Root Folders
    • Merge Templates
    • Conditional Logic
    • Merge Fields
    • Related Lists
    • Current User Fields
    • Tables
    • Generating Files
    • Updating Generated Files
    • Increasing File Size Limit
    • Limitations

Integrations

  • Merge Connect
    • Merging in the Drive Links Component
    • Merging in the Drive File Component
    • Importing Existing Drive Connect Templates
    • Merging with Flows
  • Experience Connect
    • Sharing Files & Folders Through Experience Cloud
    • Uploading through the Files Component
    • Uploading through the File Uploader Component

Billing

  • Purchase
  • Manage
    • Licenses
    • Tiers
    • Term
    • Payment Info
    • Cancellation

Products

  • eSign Connect
  • Parse Connect
  • Share Connect
  • Merge Connect
  • Drive Connect
  • Experience Connect

Pricing

  • Drive Connect Pricing
  • eSign Connect Pricing
  • Share Connect Pricing
  • Merge Connect Pricing
  • Parse Connect Pricing
  • Experience Connect Pricing

Resources

  • Documentation
  • Blog
  • Customer Stories
  • Videos
  • Company
  • Careers
  • PDO Services
  • PDO Customer Portal

© 2026 Appiphony, LLC. All rights reserved.

Various trademarks held by their respective owners.

Manage Cookies • Policy & Terms