Create Folders in Flow
A common use case is to create a set of folders any time a record (for example an Account) is created.
When creating Folders in a Flow, you must use a collection variable to store the folder names, even if you’re just creating one folder. Use the Apex Action “S-Drive Create Folders Action” to create the folders from the list of folder names.
Sample Flow
Here are the steps for a sample flow to create 3 folders when an Account is created. Some knowledge of Flows is assumed. Refer to Salesforce documentation if you need help with Flows.
Create a new record-triggered flow when an Account is created.
Use an Assignment element to list the names of your folders. Even if you only have one folder, you must put it in an Assignment element using a collection variable.
Select the Assignment element
After giving it a name (ex: Set Folder Names), 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: FolderNames)
Data Type=Text
Check the box for Allow multiple values (collection)
Click Done
Back on the New Assignment window, add your folder names
Variable = FolderNames (the api name of the variable you just created)
Operator = Add
Value = <name you want to give your folder>
Repeat for as many folders as you want to create
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 Folders Action
In the New action window:
Give it a Label and API Name (ex: Create My Folders)
Set Input Values:
File Object Name: cg__AccountFile__c
Folder Names: select FolderNames under Collection Variables
Parent Object Name: Account
Parent Record Id: start typing Record, Select Record, Select Record.Id
Relationship Name: Account__c
Click Done
Save and activate the flow
Input Values on S-Drive Create Folders Action
File Object Name: API name of the S-Drive File object. This should be typed in (it won’t be available in the search)
Folder Names: The collection variable where you stored the folder names
Parent Object Name: The API name of the parent object
Check Duplicate folders: If included, set to true to disallow folders with duplicate names.
Parent Folder Id: If included, this can be used to create subfolders. This can be done by creating the top level folders, then looping through the top folders and creating the subfolders by defining the parent folder id for the subfolder.
Parent Record Id: Id of the record the folders are being created on, such as the Account record id. 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)