You need to sign in to do that
Don't have an account?
APEX Sharing Not Working on After Insert But Does After Update
Hi everyone. So I have a requirement to share a private child object (underwriting) to the original opportunity owner. This child record is being created via a button running some javascript from the opportunity page. I have created a trigger that auto-shares it to the designated Sales Rep on each underwriting record. I am attempting to do this after insert, but it is not working. It is working perfectly if I change it to after update though.
Can anybody help me figure out why this is happening this way? Sorry if its a simple thing, I'm still a newbie in the APEX coding world.
Thanks!
trigger ShareToOppOwner on Underwriting__c (after insert) { List<Underwriting__Share> UndShare = new List<Underwriting__Share>(); For(underwriting__c und:Trigger.new){ if(und.sales_rep__c!=null){ Underwriting__Share us = new Underwriting__Share(); us.ParentId = und.Id; us.UserOrGroupId = und.Sales_Rep__c; us.AccessLevel = 'Read'; UndShare.add(us); insert us; } } }
Nevermind. Got it working!
Thanks!