You need to sign in to do that
Don't have an account?
parent record should be deleted
how to achive this--
if child record get deleteed then parent record also should get deleted in lookup relationship
if child record get deleteed then parent record also should get deleted in lookup relationship
Try this following code, and let me know if you are still facing the error.
If it still doesn't work. Please Post the errors as it as.
Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
Best,
Nithesh
All Answers
if your canon printer is not perfectly working, slow issue, not able to print anything, connectivity issue etc then quickly contact to canon printer technical support toll free number and get the quick assistance regarding Canon printer.
For more info:
http://www.apextm.com/support-for-canon-printer.php
- Create a before Delete Tigger
- Get Child record Id from Trigger.Old
- Get ParentId from the child record after Querying the child record.
- Query Parent record by the ParentId.
- Perform DML operation (delete) on that record.
This is the flow....Best,
Nithesh
That way i can provide sample code for your config and use case.
Best,
Nithesh
lets assume same test name like
parent_obj__C
child_obj__C
Let me know if it is working as you expected.
Best,
Nithesh
parent object - patient__C
child object - Appointment__C
child relationship name = Appointments
there is a field on (Appointment__C) (Loopup relationship ) called "Patient_Appointment__c " on "Patient__C"
if receptionist (user) delete appointment record patient record should get deleted this is requirment
i modified lated i replaceed your entire code with respective fields and obj name still it shows error on - parentID fild and more errors
trigger delete_child_ro_parent on Appointment__c (before delete) {
if (Trigger.isDelete){
List<Appointment__c> AllChildRecords = [Select id, ParentId From Appointment__c Where Id IN :Trigger.Old];
List<Id> ParentIdList = New List<Id>();
for(Appointment__c rec : AllChildRecords){
ParentIdList.add(rec.ParentId);
}
delete [Select id from Patient__c Where Id IN :ParentIdList];
}
}
please let me know if need any information about object ...
Try this following code, and let me know if you are still facing the error.
If it still doesn't work. Please Post the errors as it as.
Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
Best,
Nithesh
i took reference of provided code but still i shows error ' Variable does not exist: AllChildRecords '
List<Appointment__c> AllChildRecords = [SELECT id,Patient__c from Appointment__c where id IN :Trigger.old ];
}
set<Id> parentIDlist = new set<id>();
for(Appointment__c ap :
AllChildRecords){parentIDlist.add(ap.Patient__c);
i think it should iterate(AllChildRecords ) in for loop code looks fine but not allowing
Which means, You made AllChildRecords belongs to different block of code ( a local variable), So, you can't access it outside the block.
Make the List<Appointment__c> AllChildRecords as Global variable. That will work. or Bring it out of Code block.
Post the full code, so that i can make changes appropriately. Try it. and let me know if it still doesn't work.
Best,
Nithesh
trigger delete_child_ro_parent on Appointment__c (before delete) {
if (Trigger.isDelete){
List<Appointment__c> AllChildRecords = [Select id, ParentId From Appointment__c Where Id IN :Trigger.Old];
List<Id> ParentIdList = New List<Id>();
for(Appointment__c rec : AllChildRecords){
ParentIdList.add(rec.ParentId);
}
delete [Select id from Patient__c Where Id IN :ParentIdList];
}
}