Flow Actions

Create Folder (Async)

Introduction

The CloudFiles: Create Folder (Async) flow action enables you to create folders asynchronously in various external storages, such as Google Drive, SharePoint, OneDrive, and more. This action is similar to the Create Folder action but with a key difference: it executes asynchronously. Instead of providing the full details of the created folder immediately, it publishes a Folder Created event, which can trigger other automations in your Salesforce environment.

Document image


This action is ideal for scenarios requiring non-blocking execution and event-driven workflows.

Document image


What this action does

The Create Folder (Async) flow action is used in automations where folder creation should not hold up the flow's execution. Instead of waiting for folder metadata, the action allows other processes to continue while relying on the event-driven architecture to handle folder details once the folder is created.

Example Use Case

Imagine you have a flow that automatically creates folders for every new Opportunity in Salesforce. With the Create Folder (Async) action, the folder creation happens in the background, and a Folder Created event is published. This event can trigger subsequent flows, such as:

  • Creating subfolders in the newly created folder.
  • Notifying users about the folder creation.
  • Logging folder creation details in a custom object.

Input Parameters

Folder Name

  • Description: The name of the folder to be created.
  • How to Use:
    • Use Salesforce merge fields to dynamically generate folder names, e.g., {!Account.Name}.
    • Consider creating a Formula field on the object or Formula flow resource to in case you wish to have merged field names.
    • Alternatively, you can input the Folder Name as Text directly.
Document image


Destination Parameters help specify where the target folder should be created. There are multiple parameters that may need to be set based on the target cloud storage such as library, drive ID, parent folder ID etc... E.g. sharepoint users require all 3 while dropbox users may require only one.

These parameters can be easily copied from within Salesforce from using the CloudFiles > Content Library Tab.

How to Get Destination Parameters or Metadata Details ?

Some of these Parameters like DriveID can be obtained from within Salesforce CloudFiles App by navigating to the parent folder in the Content Library Tab and clicking the "View Metadata" button as shown in image below.

Document image


Follow the steps below to retrieve these IDs -

  1. Click on App Launcher on top left. Search for the CloudFiles App.
  2. In the CloudFiles App, select the Content Library Tab.
  3. Go to your cloud storage. You may need to login if you haven't done so before.
  4. Go to the target folder where you would like to place the created folders in.
  5. A dialog box opens up which shows all the IDs. Copy the ID from here.

These steps are shown in the GIF below -

Document image


Below we describe these parameters and then we show how to copy them easily with a single click.

Library

  • Description: Specifies the configured Cloud Storage where the folder should be created.
  • Valid Values: sharepoint, google, onedrive, dropbox, box, or cloudfiles (AWS S3).

Drive ID

  • Description: Required for services like Google Drive and SharePoint with multiple drives.
  • How to Get It:
    • OR Retrieve this from the Content Library Tab in Salesforce using the "View Metadata" button.

Parent Folder ID

  • Description: The ID of the folder in which the new folder should be created.
  • How to Get It:
    • Use the View Metadata option in the Content Library Tab to obtain this ID.

Example Use Case: Automating subfolder creation

  • Main Folder: An Account folder named "Trion Energies" is created using the Create Folder action.
  • Subfolder: You want to automatically create a subfolder named "Invoices" within "Trion Energies".

Steps:

  1. The Create Folder action for "Trion Energies" outputs the folder's ID as 12345.
  2. Pass this 12345 as the Parent Folder ID in a subsequent Create Folder action to create "Invoices".

Output Parameters

Folder Created Event

The Create Folder (Async) action publishes a Folder Created event instead of immediately returning metadata.

However, it does provide the Folder ID as a direct output, which can be used for related operations.

Folder ID

Document image


Description: The Resource ID of the newly created folder, which is essential for triggering further automations.

How to Get It: The Output shall be a Text variable containing the created Folder's Folder Id named after the action as Text from <Action Label> .

Warning

The output of the Create Folder action is influenced by the Folder Conflict Behavior configured for the connected cloud storage. This behavior determines what happens if a folder with the same name already exists at the specified location.

You can set the Folder Conflict Behavior in the Salesforce CloudFiles App by following these steps:

  1. Navigate to CloudFiles > Document Management > Library Tab.
  2. Locate the section for Folder Conflict Behavior.
Document image


Conflict Behavior Options:

  1. No Operation
    • What Happens: No new folder is created if a folder with the same name already exists.
    • Output Behavior:
      • The action does not create a new folder.
      • Instead, it returns the metadata of the existing folder.
    • Use Case: Ideal for scenarios where duplication should be avoided and existing folders should be reused.
  2. Rename
    • What Happens: The new folder is created with a unique name by appending a number (e.g., "Folder Name 1").
    • Output Behavior:
      • The action successfully creates a renamed folder and returns its metadata.
    • Use Case: Useful for creating unique folder structures without overwriting existing ones.
  3. Fail
    • What Happens: The action fails if a folder with the same name exists.
    • Output Behavior:
      • An error is thrown, and no folder is created.
    • Use Case: Best for scenarios requiring strict folder naming rules to avoid duplication.

Important Notes

  • Always ensure the Folder Conflict Behavior aligns with your use case to prevent unintended results or errors.
  • For troubleshooting, refer to the error message details in case of failure due to conflict.