You need to sign in to do that
Don't have an account?
munna123
apex trigger to create child record when we delete parent record
Hi all...
my requirement is when we delete a record in parent object, a new record with the deleted parent record values should be created in child object.
my requirement is when we delete a record in parent object, a new record with the deleted parent record values should be created in child object.
I have one question here ,you ar etelling you want to create child record with th evalu eof parent record when you delete the parent record right ?
So your child record will map to which parent record ? Or simply you wnat to create a child and left the record without relationship .
Which type of relation ship you have ?MD or Lookup ?
Problem is in Master detail relationship the relationship field is mandatory in child .So Can you tell me one thing which parent record will link to your child record ?
You can query for the deleted parent record, retrieve its field values and then use them to create the child record. As you have already created an 'after' trigger, just add the code to retrieve the deleted parent record as shown below -
Once you have the fields of the deleted parent record, use them for creating a new child record.
Thanks
AR
If the reply was useful and solved your problem then please mark it as best answer.