Skip to main content
Egidio Caprino a posé une question dans #Enterprise Architecture
Hello,

The right answer to this question

Universal Containers has built a recruiting application with 2 custom objects, Job Applications and Reviews that have a master-detail relationship. Users should NOT be allowed to delete review records after job application records have been approved. How would a developer meet this requirement?

seems to be this one

Use a validation rule in conjunction with a roll-up summary field

So we have a

Job Application as Master object and Review as Detail one. The roll-up summary field is in the Master one for definition. A validation rule is executed only on INSERT and UPDATE operation, not on DELETE.

I do not see how to achieve the desired result using these two features. Do you know it?
3 réponses
  1. 11 août 2015, 13:05

    Egidio - You can achieve using validation rule itself. Add the following validation rule in the master object. The rollup summary field in the below example is SUM of all child record.

    PRIORVALUE(RollupField__c ) > RollupField__c

    The above validation rule going to throw error message in the master object when the RollupField(Sum of all child account) value is less than the prior value of that same field. If you delete the detail(child) record, it will delete record(before delete operation) which will intiate the  rollup summary field to calculate new value in the parent object which is going to be an update operation in Master object which will fire the Validation rule to execute and prevent the detail record to delete from the system. All this operations will be happend in the same execution process.

    You are right validation rule is excuted only on Insert and Update operation not on DELETE operation but as per the above execution flow, its delete operation in detail object but its UPDATE operation in the master object. 

    Try adding one validation rule in the Master object as mention above and try deleting the detail record.

    Thanks,

    http://www.karanrajs.com