1

i have a situation where I need to throw an error when any use tries to edit the master record. It has one or more child records associated with it.

  • i came up with something, like i had a roll-up summary for the master record which gives the count of the associated child records.
  • now I want to put a validation rule on the Master object using the Roll up summary field.
  • I am stuck with the validation rule part.

is it feasible this way, or a trigger is required ?

1

Both are viable options. for example

  • for validation rule

    myRollupField__c > 0
    
  • for trigger

    trigger myTrigger (before update){
    
        for (SObject obj : Trigger.new){
    
            if (obj.get('myRollupField__c') > 0){
                obj.addError('bleh');
            }
        }
    }
    
| improve this answer | |
0

about the validation you provided: in that case, when ever you try to add a child record the error throws up. the error needs to pop up only when you try to edit or change the master record.

i got it resolved

AND(myRollupField__c > 0,ISCHANGED(the field you want not get edited in the masterobject))

| improve this answer | |
  • sorry if my question wasnt clear enough. – user7149 Mar 4 '14 at 15:48

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.