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
Angela Pellegrino 9Angela Pellegrino 9 

Validation Rule - Closing Cases

I am trying to write a VR that prevents a case from being closed if it's not owned by a user. It also include several other statements that should apply.  It should fire with any RT with any of the closed statuses listed but it's not.  Any assistance is greatly appreciated! Thank you!


AND
(
NOT($Setup.Global_System_Flags__c.Disable_Validation_Rules__c),
NOT CONTAINS(Source:EmailMessage.FromAddress, "@greenhouse.io"),
LEFT(OwnerId,3) <> '005',

AND(
OR(
(RecordType.Name = 'A'),
(RecordType.Name = 'B'),
(RecordType.Name = 'C'),
(RecordType.Name = 'D'),
(RecordType.Name = 'E'),
(RecordType.Name = 'E')),

OR
(
ISPICKVAL(Status, 'Closed'),
ISPICKVAL(Status, 'Duplicate'),
ISPICKVAL(Status, 'Canceled'),
ISPICKVAL(Status, 'Resolved'),
ISPICKVAL(Status, 'Reassigned')
)
)
)
VinayVinay (Salesforce Developers) 
Hi Angela,

Validation looks good,  can you try to break validation rule into small snippet and test.  First test AND scenario and then remaining ones

Thanks,
kamala swarnalathakamala swarnalatha
Hi Angela,

Could you please try this
 
AND
(
NOT($Setup.Global_System_Flags__c.Disable_Validation_Rules__c),
NOT CONTAINS(Source:EmailMessage.FromAddress, "@greenhouse.io"),
NOT(LEFT(OwnerId,3) <> '005'),

AND(
OR(
(RecordType.Name = 'A'),
(RecordType.Name = 'B'),
(RecordType.Name = 'C'),
(RecordType.Name = 'D'),
(RecordType.Name = 'E'),
(RecordType.Name = 'E')),

OR
(
ISPICKVAL(Status, 'Closed'),
ISPICKVAL(Status, 'Duplicate'),
ISPICKVAL(Status, 'Canceled'),
ISPICKVAL(Status, 'Resolved'),
ISPICKVAL(Status, 'Reassigned')
)
)
)

Please let us know if it works.

Thanks,
Kamala. K
Sweet Potato tec
Angela Pellegrino 9Angela Pellegrino 9
Thanks for your help, Vinay!