You need to sign in to do that
Don't have an account?
RudiHulsbos
How to insert a AccountSharing record linked to a Territory
Hi All,
We need to add a manual AccountSharing records for Territories. We need to manage this process manually and cannot use the standard Territory functionality. In my trigger i have the following steps:
- Get the account id
- Get the territory id
- Get the group id for the territory
- Build a list of AccountSharing records to be inserted
The trigger saves correctly, but when i try to insert an account i get the following error:
REQUIRED_FIELD_MISSING, missing required field: AccountAccessLevel (Access level should not be specified on territory manual assignment): [AccountAccessLevel]:
Here is the final insert list code example:
for(ID tid : territoryids){ insert_account_territories.add(New AccountShare( AccountId = accid, UserOrGroupId = tid, AccountAccessLevel = 'Read')); }
Please help!!!!
Thanks,
Rudi
I did something similar, then added this line:
Database.SaveResult[] lsr = Database.insert(corrShrs,false);
where corrShrs are the Share Record list (array). Also, I included a "RowCause" - which I had to define before I executed the code. Check it out in the APEX manual.