Skip to main content
Kathrin Peck ha fatto una domanda in #Collaboration
we would like to modify some fields in our objects in that way that if they are filled in the user is prompted to attach a file or the changes cannot be saved. 

 

for example: field "invoice received date". When the user puts in the date for when he/she received the invoice, he/she gets prompted to attach the invoice otherwise he/she will not be able to save the changes. 

 

Obviously the file name has to fulfil certain requirements so we can have more than one document attached to the object.

 

I wonder if you could work with criterias or if there's an app for this. My research so far has not been successful. this idea came up in the context of setting up a paperless office. I somehow think that I cannot be the first person to be after such feature/app.   

 

I'm looking forward to hearing your tipps and tricks

 

Thanks
1 risposta
  1. 18 set, 21:32

    Hi Kathrin,

    You're definitely not the first person to want this for a paperless setup! Standard Salesforce validation rules can't check whether an attachment is present before saving a record, but here are the three best ways to achieve this:

    1. Use a Visualforce Page or Flow (No-Code/Low-Code) Replace the standard record edit page with a Visualforce page or a screen Flow. When the user populates the "Invoice Received Date", you can dynamically render a file upload input on the next screen and make it a required field before allowing the final submit/save.

    2. Apex Trigger (For Strict Validation) If you want to enforce this at the database level regardless of where the record is edited:

    • Write a before update trigger on the object that checks if Invoice_Received_Date__c is changed or populated.
    • Query the Attachment (or ContentDocumentLink) child records for that object.
    • If no attachment matches your required naming criteria, use addError() to prevent the save and display your custom error message (e.g., "You must attach the invoice document before saving this date.").

    3. AppExchange Route Search the AppExchange for "Required Attachments" or "File Upload Validation" apps. There are several pre-built managed packages designed specifically to enforce mandatory file attachments based on field criteria or stage gates.

    Hope this gives you a good direction for your paperless office initiative!

0/9000