function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
trublutrublu 

Insert AccountShare does not insert!

Hi all,
 
I am using the following code in my addafterUpdateOnAccount and addAfterInsertOnAccount triggers to manually add AcountShare records to Table Accountshare when an account is updated/added.
 
However, the code does not actually insert any AccountShare records in the Insert trigger.I am very very confused because the same code work in the Update trigger... Also, based on my debug code, there is no run-time error from executing the insert or update trigger.
 
Could anyone please help? Why is the "insert" not working when an account is added, but works when an account is updated?
 
Thanks a lot!!!
=================================================

AccountShare newAccountShare = new AccountShare();

newAccountShare.accountid = theAccountid;

newAccountShare.AccountAccessLevel = 'Edit';

newAccountShare.OpportunityAccessLevel = 'None';

newAccountShare.CaseAccessLevel = 'None';

newAccountShare.UserOrGroupId = newProspectManagerId;

addAccountShares.add(newAccountShare);

insert addAccountShares;