Skip to main content
Hey guys,

 

I wrote the following validation rule but it doesn't do what I need. any thoughts on how I can prevent more than one inactive record at a given time?

 

AND(Active__c = FALSE, Count__c > 0)

 

Error: Count field doesn't exist. How can I get the count of inactive records and then compare?

 

 
3 Antworten
  1. 10. Feb. 2017, 13:26
    Jo, a validation rule won't help here since you are trying to do a comparison with other records (kind of looping through them). We can do this easily using a workflow rule + field update + Unique field combo. Here's the design for it:

     

    1. Create a unique text field on the object: UniqueInactiveID

     

    2. Create a workflow rule and field update with the rule criteria:

    OR(

    ISCHANGED(Active__c),

    ISNEW()

    )

     

    Field Update:

    IF(Active__c = FALSE, 'FALSE', NULL)

     

    Activate the workflow rule. What this does is that whenever two records are created or edited with the Active flag set to FALSE, the unique field would try to store a dulpicate value of 'FALSE' and wouldn't allow this to happen. 

     

    Two things to note

    :

    • If there are existing records, you must run a retro-active update using data loader after setting up the unique field and workflow rule + field update
    • The duplicate error message isn't customizable and will show something like: Error:Duplicate value on record: Id: xxxuuuyyyrrrieee