I have the following situation:

In my Salesforce "opportunity" object I need to make mandatory to attach specifics files in order to set the record in a specific stage.

Like the following:

In order to insert the opportunity in the "Stage A", my end-user must upload a specific .pdf file.

In order to insert the opportunity in the "Stage B", my end-user must upload another specific .pdf file.

In order to insert the opportunity in the "Stage C", my end-user must upload another specific .pdf file.

In another CRM that I used to use, I had the option to insert a "file-upload" field and make it mandatory in these stage updates, it worked like a charm.

How can I get this done using Salesforce?

Best regards,

  • 1
    You are going to need custom fields on Opportunity that track whether said file has been uploaded. Then a trigger on ContentDocumentLink to detect file name, and setting relevant value on Opportunity. Sadly, you can't have Flows be triggered on ContentDocumentLink
    – cropredy
    Commented Sep 27, 2022 at 20:15

1 Answer 1


In Salesforce, you can't create a child record before creating its parent record. Thus, any kind of automation would always see that there's no file uploaded and trigger a validation error. How many of us typically handle this is by refusing the opportunity to be edited once created until the appropriate file is uploaded, perhaps with a field to check that is checked by automation when the file is attached, or by a trigger when the opportunity is being edited, etc.

Of course, all of this is just with out-of-the-box stuff. This is Salesforce, so there's almost always a workaround once code gets involved. For example, you can create a custom component that won't create the opportunity until a file is uploaded somewhere, such as on the Account (see lightning-file-upload), which you'd link afterwards using ContentDocumentLink. From there, you can override the default Opportunity New action to show your custom component. You can even add a trigger to prevent the opportunity from being created through other means (e.g. an API call) unless being called from your custom component.

  • Hello, thanks for the reply. Yeah, I got it. I must create a field that is updated via automation when the specific file is uploaded. Whenever I try to pass the oportunity to the next stage, it would check if this field is updated and would return an error message if it wasn't. But as I said, I have a few files to be inserted for each stage, hence, a few fields to do that automation are needed. How can I map the following: - when I upload the file x, the field y is updated; - when I upload the file z, the fielz w is updated; Can you tell me how can I get this done? Best r. Commented Sep 28, 2022 at 13:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .