You need to sign in to do that
Don't have an account?
raysfdc1988
trigger to avoid multiple child records for its parent record.
Hi All,
Lemme expalne in detail..
There two objects called Case(Master parent) and Logsheet(child)
Say there are 3 cases...
caseA
CaseB
CaseC
now i should create only one child record for each parent case record..
Means.. for caseA , only one logsheet1(record of Logsheet)
Means for one CASE ID i should not create multiple Logsheet records,...
Please hlep to to write a trigger to avoid this duplication....
Lemme expalne in detail..
There two objects called Case(Master parent) and Logsheet(child)
Say there are 3 cases...
caseA
CaseB
CaseC
now i should create only one child record for each parent case record..
Means.. for caseA , only one logsheet1(record of Logsheet)
Means for one CASE ID i should not create multiple Logsheet records,...
Please hlep to to write a trigger to avoid this duplication....
AND ( ISNEW() , parentobject__r.rollupfield__c > 0 )
All Answers
If you dont want to go the code way, maybe you can try adding a rollup summary field and validation rules.
1.) Create a roll-up summary field on parent object to count number of child records.
2.) Write a validation rule on child object to avoid creation when the field on the parent is greater than zero.
But using validation rule also sounds good...
Ok I can create roll-up summary field on parent object..
But how to write a validation on child object..
Say I have created LogshhetCount(rollup field on parent object)
then how to validate it on child object Logsheet
Please help me to write validation rule
AND ( ISNEW() , parentobject__r.rollupfield__c > 0 )