2

I have object called Carset.In Carset am having a field "Valid" checkbox.

If the checkbox is checked then i cannot edit or delete the related list record(Child object-Service)

for editing i have written the below validation rule.It's working.

  IF(Car_Set__r.valid__c,true,false)

But for delete how to handle it using validation rule ?

4
  • you need to handle delete case using trigger
    – Ratan Paul
    May 27, 2016 at 11:57
  • without using trigger we can't handle ?
    – uma451
    May 27, 2016 at 11:58
  • developer.salesforce.com/forums/?id=906F00000008qy2IAA here answer is choosen .am not able to get it
    – uma451
    May 27, 2016 at 11:59
  • uma that's only for update case. since validation rule doesn't fire on delete of record. You need to go with a simple trigger approach to prevent deletion
    – Ratan Paul
    May 27, 2016 at 12:01

1 Answer 1

6

Since validation rule doesn't fire on delete of record. You need to go with a simple trigger approach to prevent deletion

trigger triggerName on CustomObject__c (before delete)
{
   for(CustomObject__c obj: Trigger.old)
   {
     if(obj.valid__c) 
     {
        obj.addError('You can not delete this record');
     }
   }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .