By default ResinFiles uses the Context provided by Salesforce in the form of a Signed Request. It is possible to override some of these parameters to help match your folder structure. We modify the VisualForce to achieve this.
The Account’s name will be used as the folder name to look for
<apex:page showHeader="false" standardController="Account">
<apex:canvasApp
applicationName="ResinFiles"
parameters="{
recordName: '{!JSENCODE(account.name)}',
actualHeight: document.documentElement.clientHeight
}"
width="100%"
height="800px"
scrolling="no" />
</apex:page>
A custom field defines the folder name to look in Google Drive for.
<apex:page showHeader="false" standardController="Account">
<apex:canvasApp
applicationName="ResinFiles"
parameters="{
recordName: '{!JSENCODE(account.name)}',
recordFolderPath: [
'{!JSENCODE(account.Folder_Name__c)}'
],
actualHeight: document.documentElement.clientHeight
}"
width="100%"
height="800px"
scrolling="no" />
</apex:page>
Opportunities are nested within the Account’s folder.
e.g. My Drive > Salesforce > Accounts > Dickenson Plc > Opportunities > Bricks and Mortar
<apex:page showHeader="false" standardController="Account">
<apex:canvasApp
applicationName="ResinFiles"
parameters="{
recordName: '{!JSENCODE(account.name)}',
recordFolderPath: [
'{!JSENCODE(opportunity.account.name)}',
'Opportunities',
'{!JSENCODE(opportunity.name)}'
],
actualHeight: document.documentElement.clientHeight
}"
width="100%"
height="800px"
scrolling="no" />
</apex:page>
Sometimes you need slightly more complicated logic to map your Records to your Google Drive folders. For example you may store archived Opportunities in a separate folder structure.
Imagine the following folder structure:
To get this to work we’ll need to create an Apex class withe the following contents:
public class RFOpportunityMapping {
private final Opportunity oppo;
public RFOpportunityMapping(ApexPages.StandardController controller) {
controller.addFields(new List<String>{'StageName'});
this.oppo = (Opportunity)controller.getRecord();
}
public String getRecordFolderName() {
if (oppo.StageName == 'Delivered' || oppo.StageName == 'Returned' || oppo.StageName == 'Closed Lost'){
return 'Archived Opportunities';
}
return 'Current Opportunities';
}
}
Then we’ll need to add extensions
to our VisualForce. For example:
<apex:page showHeader="false" standardController="Opportunity" extensions="RFOpportunityMapping">
<apex:canvasApp
applicationName="ResinFiles"
parameters="{
recordName: '{!JSENCODE(opportunity.name)}',
recordFolderPath: [
'{!JSENCODE(recordFolderName)}',
'{!JSENCODE(opportunity.name)}'
],
actualHeight: document.documentElement.clientHeight
}"
width="100%"
height="800px"
scrolling="no" />
</apex:page>
Notes:
recordFolderName
, not getRecordFolderName
inside the VisualForce.