Create Shortcuts in Flow
A common use case is to create a shortcut on another record when a file is uploaded. For example, when an Opportunity File is uploaded, create a shortcut to the file on the Opportunity’s Account.
When creating Shortcuts in a Flow, you must use a collection variable to store the source file id, even if you’re just creating one shortcut. Use the Apex Action “S-Drive Create Shortcuts Action” to create the folders from the list of folder names.
Sample Flow
![](../__attachments/2059209914/image-20230105-210124.png?inst-v=45374f53-f4b0-4a30-83dc-edc14e9d1f8c)
Here are the steps for a sample flow to create a shortcut on the parent account of an opportunity whenever an opportunity file is uploaded. Some knowledge of Flows is assumed. Refer to Salesforce documentation if you need help with Flows.
Create a new record-triggered flow that triggers when a file is uploaded to an Opportunity. The triggering object is Opportunity File. Because of the way S-Drive works when files are uploaded, you must specify the following entry conditions:
Field = cg__WIP__c
Operator = Is Changed
Value = False
Use an Assignment element to list the names of your source files (the files you want to create shortcuts for). Even if you only have one file, you must put it in an Assignment element using a collection variable.
Select the Assignment element
After giving it a name (ex: Store source file ids), under Variable, click New Resource. This will be the variable where you list your folders
In the New Resource popup:
Resource Type=variable
Give it an API Name (ex: SourceFiles)
Data Type=Text
Check the box for Allow multiple values (collection)
Click Done
Back on the New Assignment window, add the file ids of the files you want to shortcut
Variable = SourceFiles (the api name of the variable you just created)
Operator = Add
Value = go to the record that triggered the flow and traverse to the id field ({!$Record.Id})
Click Done
In the Flow canvas, add an Action element
Filter by Type
click Apex Action
Type S-Drive in the search box and choose S-Drive Create Shortcuts Action
In the New action window:
Give it a Label and API Name (ex: Create Shortcut on Account)
Set Input Values:
Destination File Object Name: cg__AccountFile__c
Source File Ids: select SourceFiles (created above) under Collection Variables
Source File Object Name: cg__OpportunityFile__c
Parent Record Id: traverse from the record that triggered the Flow, to the Opportunity to the Account id ({!$Record.cg__Opportunity__r.Account.Id})
Click Done
Save and activate the flow
Input Values for S-Drive Create Shortcut Action
Destination File Object Name: API name of the object the shortcut will be (ex: cg__AccountFile__c) This should be typed in (it won’t be available in the search)
Source File Ids: The collection variable where you stored the file ids of the files to be shortcutted
Source File Object Name: The API name of the object of the source files (ex: cg__OpportunityFile__c)
Parent Folder Id: If included, this can be used to put the shortcut inside a folder.
Parent Record Id: Id of the record where you’re creating the shortcut, such as Account record id in the example here. This is not needed for S-Drive Tab (S3Object)
Relationship Name: This is the lookup field to the parent, such as cg__Account__c or Parent__c. It is not needed for S-Drive Tab (S3Object)