You need to sign in to do that
Don't have an account?
HARSHIL U PARIKH
Trigger does not allow deletion of record
Hello Developers,
Need your thoughts/help..
I have a trigger on child object which updates check box on contact as True on creation of child. (This happens in below trigger)
But it doesn't allow me to delete the child for that contact anymore.
This trigger is created to just update the record of parent. So my other triggers can fire. So, having checkbox checked or not checked don't really matter. Its all about update.
Thank You!
Well, one more Q) Can we update parent record (just update) when child is created, deleted, updated etc.. with process builder? IF yes, then I can take that path instead of trigger above.
Thank you guys for help!
Need your thoughts/help..
I have a trigger on child object which updates check box on contact as True on creation of child. (This happens in below trigger)
But it doesn't allow me to delete the child for that contact anymore.
Trigger CrossObjectContactUpdate on Merchandise__C(after delete, after insert, after update){ List<Merchandise__c> Merch = New List<Merchandise__C>(); List<Contact> Con = New List<Contact>(); Set<ID> ConID = New Set<ID>(); for(Merchandise__c M: Trigger.New) { ConId.add(M.Individual_Customer__C); } Boolean T = True; Contact Con1 = [Select X_CrossObj__c From Contact Where ID IN: ConID]; for(Merchandise__C MC: Trigger.New) { Con1.X_CrossObj__c = T; } update Con1; }
This trigger is created to just update the record of parent. So my other triggers can fire. So, having checkbox checked or not checked don't really matter. Its all about update.
Thank You!
Well, one more Q) Can we update parent record (just update) when child is created, deleted, updated etc.. with process builder? IF yes, then I can take that path instead of trigger above.
Thank you guys for help!
-Art
All Answers
I think the problem is with Trigger.New. Basically when you delete the record Trigger.New will no longer exist.
You have two options here. 1) simply take out 'after delete' from your trigger declaration. Sp, you forst line will look like: Trigger CrossObjectContactUpdate on Merchandise__C(after insert, after update).
2) if you want to keep 'after delete' in your trigger declaration:
Hope this helps.
Art.
When I do mass update (using installed app for Mass edit/update/delete from list view) of the record then it throws an error like this:
Error:
CrossObjectContactUpdate: execution of AfterUpdate caused by: System.QueryException: List has more than 1 row for assignment to SObject () No record updated
Thank you for the followup!
-Art