Use Case #1: Upload a Single File

Get a working example of the standard screen component for uploading a single file and relating it to a record. This post is part of the Uploading and Working with Files in Flow mini series.

Ingredients:

  • Install/setup flow package
  • Flow:  E01_001_UploadSingleFile
  • Standard File Upload flow screen component (included in the flow)
  • Case object – need at least one case record in your org

Video Tutorial (4 min)

What’s Happening in the Flow:

  1. Flow starts by looking for an input variable called caseRecordId.
  2. “Get Case” query: Uses the caseRecordId input variable to query for the current Case and returns its field values. In this sample, we’re only using this info in the display text on the next screen for fun.
  3. “Upload a Single File” screen: Displays user-facing text and the standard File Upload screen component. For a single upload, the component only has a few key properties to set:
    1. Allow Multiple Files – for single upload only, this gets set to false (technically, {!$GlobalConstant.False}).  This is the only substantive difference from the “Upload Multiple Files” sample flow.
    2. Related Record ID – pop in the input variable, caseRecordId, so that the file is automatically associated to the case when it’s uploaded.
  4. Checking for an uploaded file. Unfortunately, the File Upload component doesn’t have a property to make it required; so when the user clicks “Next”, we want to make sure they uploaded a file. If not, we’ll send them back to the screen and display an instructional error message.
    1. “Count Content Docs” assignment: This counts the number of ContentDocument Ids saved by the File Upload component and stores the count in the varContentDocCount variable. The count should only be “1” because we didn’t allow multiple file uploads.
    2. “File Uploaded?” decision: Based on the count, let’s direct the user:
      1. When the count equals 0, the “Set Flag” assignment element sets the varFlagFileNotUploaded variable to true. Then, when we redirect the user back to the upload screen and use that flag to show an error message using conditional visibility.
      2. When the count is greater than 0, the flow proceeds.
  5. “Finished” screen: No real purpose except to show you the output variables that come from the File Upload component.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: