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 ?

2 Answers 2

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');
            }
        }
    }
    
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))

1
  • sorry if my question wasnt clear enough.
    – user7149
    Commented Mar 4, 2014 at 15:48

You must log in to answer this question.

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