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 ?

  • you need to handle delete case using trigger – Ratan Paul May 27 '16 at 11:57
  • without using trigger we can't handle ? – uma451 May 27 '16 at 11:58
  • developer.salesforce.com/forums/?id=906F00000008qy2IAA here answer is choosen .am not able to get it – uma451 May 27 '16 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 '16 at 12:01
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');
     }
   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.