function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pugalagiri JPugalagiri J 

Rollup summary or count of attachment in Validation formula field

Is it possible to check if there are any attachment available in validation formula field?

Lets say Object A
Validation rule in Object A - to check count of attachments and throw validation accordingly
Best Answer chosen by Pugalagiri J
VinayVinay (Salesforce Developers) 
You can write a trigger that will count the no. of attachments and store the same value to a custom field on object A .  

Also you cannot create rollup on notes and attachments.  Below is the Idea link for same.

https://trailblazer.salesforce.com/ideaView?id=08730000000Bpze
 
As an alternate approach you can check Rollup Helper app from Appexchange which will allow you to rollup the count of Attachments.

https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009i3UpEAI

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
You can write a trigger that will count the no. of attachments and store the same value to a custom field on object A .  

Also you cannot create rollup on notes and attachments.  Below is the Idea link for same.

https://trailblazer.salesforce.com/ideaView?id=08730000000Bpze
 
As an alternate approach you can check Rollup Helper app from Appexchange which will allow you to rollup the count of Attachments.

https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009i3UpEAI

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
This was selected as the best answer
Pugalagiri JPugalagiri J
Thanks for quick response Vijay

We do have existing implementation -> logic build in trigger before to check number of attachments and perform needed validation.
I was actually exploring options to achieve this via custom validation rile :-)

Since there is no other options, needed to go with scrpting only (trigger before)