Salesforce Obscura: Update a field when you upload a file (with Flows!)

One more way to use Screen Flows to manage Files while tracking exactly which files have been uploaded

The video walk through for this post
  • Creating and completing a Task for each requirement.
  • Creating custom fields so they can check a box (please don’t*) or enter a date (MUCH better!) to indicate the completion of each requirement.
  • Adding a record to a custom child object for each requirement.

Example Use Case and Solution Overview

Our example nonprofit needs to track whether its applicants have submitted a resume, two essays and a photo. The applicant can’t be evaluated for entry into the program without all of these items completed.

  1. Prepare the Application record with your requirements fields
  2. Create a Screen Flow and set up its Resources
    (2a) New Resource: AppRecordID
    (2b) New Resource: UploadedCVIds
  3. Create the file upload screen
    (3a) Create the Screen element
    (3b) Add the picklist component
    (3c) Add the file upload component
  4. Process the uploaded file and update the Application record
    (4a) Decision: Do we proceed? If so, what type of file was uploaded?
    (4b) Update Record: Update Application
    (4c) Save and Activate your Flow
  5. Embed the Screen Flow into the Lightning Record page
    (5a) Drag the Flow onto the Lightning Record Page
    (5b) Configure the Flow Component

(Step 1) Create requirements fields on your object.

  • I added 4 Date fields — one for each requirement — on my Application object. Your details will obviously differ from mine.
  • I also added a formula field that shows me when all requirements are met, for easy filtering in list views.
Four new date fields to track requirements
The starting point for our Application page layout — Files is visible and our Requirements fields are also visible, but it would currently be a manual process to track both

(Step 2) Create a new Screen Flow and Set Up Resources

The overview of my Screen Flow is below. Because this is being integrated into an internal Lightning Record page, I’m not doing the “do we have all of our data” checks that we did in the last solution. If you want nicer error messages, you certainly can do that check first.

The full Screen Flow overview, designed to be embedded in an Application Record page
Setting up the Application Record ID variable for use throughout the flow
  • Resource Type: Variable
  • API Name: AppRecordID
  • Description: This variable contains the ID of the Application Record that embeds this flow
  • Data Type: Text
  • Make sure to check the box next to Available for Input
Set up a collection variable to capture the returned data from the File Uploader
  • Resource Type: Variable
  • API Name: UploadedCDIDs
  • Description: This collection contains the record set required by the file uploader to get the Content Version IDs back
  • Data Type: Text
  • Check the box next to “Allow multiple values (collection)”

(Step 3) Create the File Upload Screen

Now that you have the prep work done, you can start building your screen flow. This is a very simple screen that captures the type of requirement this file satisfies, and the File Uploader itself.

The Screen that allows a user to upload a file and specify which requirement it’s for
  • Click + to start your Flow, and choose “Screen”
  • Screen Properties: Label: Upload Requirement Document
  • Screen Properties: Description: Upload a document to satisfy a program requirement.
  • Configure Header: Check “Show Header” and (optional) Show Help Text.
  • Configure Footer: Check “Show Footer”.
  • Configure Footer: Next or Finish Button: Use a Custom Label (“Save File”)
  • Configure Footer: Previous Button: Hide Previous
  • Configure Footer: Pause Button: Hide Pause
An example of the Picklist configuration with manually-assigned choices
  • Under “Components” on the left-hand side, find “Picklist” and drag it into the center panel.
  • Label: Requirement Satisfied by this Document
  • Check the box next to “Require”
  • Configure Choices: Let Users Select Multiple Options: No
  • Component Type: Picklist
  • Choice: Enter the first choice of your picklist and click “+ Create [choicename] Choice” to save it as an option. Do this until all choices are set.
How to manually add a choice to a picklist in a Flow
Manage the file upload — set the Related Record ID
  • API Name: UploadDocument
  • File Upload Label: Upload Document
  • Accepted Formats: leave this blank unless your requirements are of a specific file type (e.g. .pdf)
    Note: you can just type in a comma-separated list of accepted formats
  • Allow Multiple Files: False
    Note: click into this field and type false. It will set the field to {!$GlobalConstant.False}
  • Content Document IDs: LEAVE THIS BLANK
  • Content Version IDs: LEAVE THIS BLANK
  • Disabled: leave this blank
  • Hover Text: leave this blank or put some sort of help text in if you prefer
  • Related Record ID: {!AppRecordID}
    Find the AppRecordID resource you set up in step 2a.
  • Uploaded File Names: leave this blank
  • Optional: Set Component Visibility: I have left this to “Always”
  • Check the box for “Manually Assign Variables”
  • Leave everything else blank except for Content Document IDs
  • Content Document IDs: {!UploadedCDIDs}
    Find the UploadedCDIDs collection resource you created in step 2b.
  • Revisited Screen Values: Check next to “Refresh inputs to incorporate changes elsewhere in the flow”
Put the UploadedCDIDs into the Advanced section

(Step 4) Process the uploaded file and update the Application record

This next step of the Flow will process the uploaded file so that we know which requirement date to set.

An example of the Decision component that determines if we have a successful file upload and, if so, what type of file was uploaded
  • Click + to under your screen and choose “Decision”
  • Label: What Type of File
  • Description: What type of file was uploaded?
  • Label: Photo Uploaded
  • Condition Requirements to Execute Outcome: All Conditions are Met (AND)
  • Set up the first condition: Requirements_Satisfied_by_this_Document [Equals] Photo
    In this condition, we are asking if the picklist on the File Upload screen was set to our first choice, which for this example is Photo.
  • Set up the second condition: UploadedCDIDs [Is Null] False
    In this condition, we are asking if the file uploaded successfully. Under Resource, choose the UploadedCDIDs resource you set up in step 2b.
The first of the Update Records actions, one for each decision branch. This one update the Photo requirement date.
  • Click + to under your first decision branch (ours is called “Photo” to indicate a photo was uploaded) and choose “Update Record”
  • Label: Update Application with Photo
  • Description: Update the Photo Requirement date
  • How to Find Records to Update and Set Their Values: Specify conditions to identify records, and set fields individually
  • Object: Application
    Choose the object that started your flow. Ours is called Application.
  • Condition Requirements to Update Record: All Conditions are Met (AND)
  • Condition: ID [equals] AppRecordID
    Find the AppRecordID resource you set up in step 2a.
  • Set Field Values for the Application Records: Field: Date_Photo_Received__c
    Choose whichever requirement field corresponds to the upload of the first picklist item. For us, if the file uploaded is a Photo, then we update the Date Photo Received field on Application.
  • Set Field Values for the Application Records: Value: $Flow->Current Date
    In this field, look for $Flow from the list of options. Click on it and choose Current Date.
When setting the value of a field, look for $Flow >
Once you click on $Flow > choose CurrentDate

(Step 5) Embed Your Flow into a Lighting Record Page

The last step is to allow your users to access and launch your flow. We wanted to embed this right above the File list on the Application page, so that’s what this example shows.

Drag the Flow Component into your page layout
Set up your Flow component and pass in the Record ID
  • Click on the component to open up its contextual configuration window.
  • Flow: Upload Requirements Document
    or whatever you named the flow you created in steps 2–4
  • Check the box next to “Pass record ID into this variable” under the “AppRecordID” variable.
  • Save and publish.

(Step 6) Test it out

Go to your record and upload a file. You should see your requirement automatically captured and the file linked to the record.

--

--

Operationalizationer — one who defines a fuzzy concept so it becomes clear, measurable, and empirically observable. Founder @ deepwhydesign.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jenn Taylor

Operationalizationer — one who defines a fuzzy concept so it becomes clear, measurable, and empirically observable. Founder @ deepwhydesign.com