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
MagsbMagsb 

Validation Rule to Prevent Closure of Case with Pending Tasks

I need help creating a validation rule that will prevent users from closing a case if there are any open/pending tasks associated with it. Would this be best done as Case Validation Rule? 
Best Answer chosen by Magsb
jigarshahjigarshah
Follow the below approach to prevent closure of Pending Tasks associated with a Case.

1. Create a custom field of type Number (18, 0) on Case called as Pending Task # (Pending_Task_Count__c).

2. Since out of box Rollup Summary fields will not be supported, use one of the below mechanisms to Rollup the Count of Tasks with Status = Open or Pending to the Pending Task # field on Case.
  • Build an Apex trigger that counts the Open or Pending Tasks every time after a Task is created or updated with a Case record.
  • Install and setup a Declarative Rollup Summary helper, a free tool from Appexchange that helps implement rollups without code.
3. Implement a Validation Rule on Case that checks the following criteria.
AND(
	IsClosed = TRUE,
	Pending_Task_Count__c > 0
)

This should help accomplish your requirement.

Please mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.