I am trying to display a finish screen after a file upload which should be displayed only if the file upload was a success, so need to add a decision element.I tried using a text collection variable for the document Id in file upload and checking if it's not null in the decision element but it doesn't work
-
I can't do a screenshot on mobile as Salesforce blocks that,, nor can I open the flow elements on mobile, but I was able to do this using an assignment that sets the length of a variable, and evaluating that variable in the decision element. I'll look at the details when I'm at a desktop.– goravCommented Sep 20, 2020 at 17:40
2 Answers
When I did this about 6 months ago, I manually mapped the contentDocumentIds to a collection variable. It ought to work without that, but I went the manual route, and I would like to believe that was for a good reason.
Then I used an assignment element to set a number variable equal to the size of the collection variable via the equals count
operator.
The decision evaluates the number variable and routes to an error screen if no attachment was uploaded.
Not so elegant, but it works. Screenshots below
flow overview
manual mapping (for file upload element in scrUploadFile)
assignment asstSetLength
I did something similar to @gorav and found a way to do it a bit simpler.
- Don't need to manually assign variables on the upload component. Do still use the collection variable to store the Content Document IDs, which is always required.
- Create a number variable to hold the count. I set the default value to 0 (not sure if that matters or not). Use Assignment to set your number variable to EQUALS COUNT of [select the upload screen component > Content Document IDs].
- Decision element: If the count variable = 0, no documents were uploaded
Hope this helps anyone else who comes looking for an answer here, and thanks to @gorav for pointing out the need for the assignment element and count variable!