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
JesipJesip 

Update Account Team Access

My organization has recently changed the org-wide default for Accounts from Public Read/Write to Public Read/Only.  An unexpected consequence of this change was that all Account Team Members who had Read/Write Access to accounts were updated to be Read Only.  We would like to programmatically update all of the account team members back to Read/Write.

It appears that there are two objects involved in this process.  First, the AccountTeamMember object holds the relationship between all Account Team Members and the Account.  Second, the AccountShare object holds the security level if it is "not trivial."  Knowing that we cannot update the RowCause field on the AccountShare object, we can insert records through the API where the RowCause is "Manual", but the Account Team Member still shows as "Read Only" when I go view the account.  Although I think that adding these "Manual" records to AccountShare will grant the user the access they need, the user's access is not obvious when looking at the account.

My question is, how do these "Manual" AccountShare records show themselves in the application?  And is there anyway that I can programmatically update the Account Team so that these relationships are more intuitive?  (We would do it manually, but this problem affects more than 200,000 account team member relationships.)

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
benjasikbenjasik
Your best bet is to insert a row into AccountShare with the desired level of access for each team member associated with an account.

We'll handle the upsert logic in the API for you. If there's already a manual share, we'll upgrade it to a "team" share. A team share is just another type of manual share. If there's already a team share, we'll update what's there. If it's a trivial share (not granting more access than the default), we'll reject it. But if you're r/o, r/o, r/o, and you inserted r/w, r/o, r/o, the system should accept all of those.

Test this out on a few records, and if you're inserting 200k records, you'll for sure want to do 200 at a time.

If you haven't seen the sharing screen, go to an account, click on the sharing button, and then there's an expand list button, that will give you all the shares, and why they are there.

Sharing can be a bit daunting, but it's not that bad.

Benji

All Answers

benjasikbenjasik
Your best bet is to insert a row into AccountShare with the desired level of access for each team member associated with an account.

We'll handle the upsert logic in the API for you. If there's already a manual share, we'll upgrade it to a "team" share. A team share is just another type of manual share. If there's already a team share, we'll update what's there. If it's a trivial share (not granting more access than the default), we'll reject it. But if you're r/o, r/o, r/o, and you inserted r/w, r/o, r/o, the system should accept all of those.

Test this out on a few records, and if you're inserting 200k records, you'll for sure want to do 200 at a time.

If you haven't seen the sharing screen, go to an account, click on the sharing button, and then there's an expand list button, that will give you all the shares, and why they are there.

Sharing can be a bit daunting, but it's not that bad.

Benji
This was selected as the best answer
enrico fantinienrico fantini

I've got some java code that tries to insert a team account members and sharing access with Edit permission on Account and Read on the Opportunity and Case. Unfortunately, eventhough i do not get any error back from API, on salesforce i do only see default values, such us Read Only and Private.

The code looks basically like the following:

        currAccTeamMem= new AccountTeamMember();
        currAccTeamMem.setAccountId(currentAccount.getId());
        currAccTeamMem.setUserId(currUserCRD.getId());
        
        currAccTeamMem.setTeamMemberRole("CRD");
        accountTeamMembers.add(currAccTeamMem);

        currAccShare= new AccountShare();
        currAccShare.setAccountId(currentAccount.getId());
        currAccShare.setUserOrGroupId(currUserCRD.getId());
        currAccShare.setAccountAccessLevel("Edit");
        currAccShare.setOpportunityAccessLevel("Read");
        currAccShare.setCaseAccessLevel("Read");

        //currAccShare.setRowCause("Team");  

        accountShares.add(currAccShare);

Any help is really appreciated.

Thanks

Enrico