You need to sign in to do that
Don't have an account?
Cant create AccountTeamMember with AccountAccessLevel = "Edit" with API?
I've been round-and-round with this one. All I'm trying to do is create an AccountTeamMember object and then use sforceService.create() to add it. I can do it if I don't set AccountAccessLevel = "Edit". If I don't, AccountAccessLevel is set by default to "Read". The problem is, I want AccountAccessLevel to be "Edit". If I set AccountAccessLevel = "Edit", then when I execute the create() method the following exception is thrown:
Unable to create/update fields: AccountAccessLevel. Please check the security settings of this field and verify that it is read/write for your profile.
I've tried everything to remedy this situation, including setting the API user to the top role of the company (CEO), making the API user the owner of the account, checking every capability in the API user's profile, and creating account sharing rules. Nothing makes a difference. In fact, I can log in as the API user and create AccountTeamMembers with "Edit" access at Salesforce.com-- just not with the API.
Has anyone been able to do this? Please help.
Finally! Creating the AccountShare object was the real key. My errors after implementing that occurred because I was trying to set AccountShare.RowCause = "Team", which is not allowed from the API and not necessary, and I was not setting AccountShare.OpportunityAccessLevel, which is required. My working code is below.
Thanks for all the help!
AccountTeamMember newAccountTeamMember = new AccountTeamMember();
// Cannot set AccountAccessLevel here-- not allowed with the API. Defaults to "Read"
newAccountTeamMember.AccountId = accountId;
newAccountTeamMember.TeamMemberRole = userAccountTeamMembers[i].TeamMemberRole;
newAccountTeamMember.UserId = userAccountTeamMembers[i].UserId;
newAccountTeamMembers[i] = newAccountTeamMember;
//Should not set AccountShare for the owner but for others
if (userAccountTeamMembers[i].UserId != account.OwnerId)
{
AccountShare newAccountShare = new AccountShare();
newAccountShare.AccountAccessLevel = "Edit";
newAccountShare.AccountId = accountId;
newAccountShare.OpportunityAccessLevel = "Read";
newAccountShare.UserOrGroupId = userAccountTeamMembers[i].UserId;
newAccountShares[i] = newAccountShare;
}
All Answers
so once you create the account team member by default the access level is set to read. now go to account share check for the account share record using account id and user id. set the accesslevel to read/write here. this should solve your problem.
let me know if this works
I think what you will need to do is create an account team member and then immediatly add a row in the account share table with the correct set of permissions..
Hope it helps
Sadly, I'm implementing this solution and running into the same issue:
In our new code, we are adding the AccountTeamMember with default AccountAccessLevel (Read), and then trying to create an AccountShare object for each new AccountTeamMember with RowCause = “Team”. But as with before, we are getting an error. The error is:
Unable to create/update fields: RowCause. Please check the security settings of this field and verify that it is read/write for your profile.
…Same as before. We’ve again tried to set the Role of the API user to “CEO” (top of the company) to make sure it’s not a permissions issue. Here is our adjusted code…
AccountTeamMember newAccountTeamMember = new AccountTeamMember();
// Cannot set AccountAccessLevel here-- not allowed with the API. Defaults to "Read"
newAccountTeamMember.AccountId = accountId;
newAccountTeamMember.TeamMemberRole = userAccountTeamMembers[i].TeamMemberRole;
newAccountTeamMember.UserId = userAccountTeamMembers[i].UserId;
newAccountTeamMembers[i] = newAccountTeamMember;
// Should not set AccountShare for the owner but for others
if (userAccountTeamMembers[i].UserId != account.OwnerId)
{
AccountShare newAccountShare = new AccountShare();
newAccountShare.AccountAccessLevel = "Edit";
newAccountShare.AccountId = accountId;
newAccountShare.RowCause = "Team";
newAccountShare.UserOrGroupId = userAccountTeamMembers[i].UserId;
newAccountShares[i] = newAccountShare;
}
Still trying!!!!!!!
Thanks for the hint in "Updating" the AccountShare record but that too didn't work. When instead of creating the AccountShare records I tried to first query them for the account and then update them with AccountAccessLevel = "Edit", I got this error message:
Unable to create/update fields: UserOrGroupId. Please check the security settings of this field and verify that it is read/write for your profile.
Same issue. So frustrating...
Actually, when I had the proper AccountId set for the AccountShare object, the exact exception is:
Unable to create/update fields: UserOrGroupId, AccountId. Please check the security settings of this field and verify that it is read/write for your profile.
...and when I add RowCause = "Team" to the update record the exception cites all 3 fields:
Unable to create/update fields: UserOrGroupId, AccountId, RowCause. Please check the security settings of this field and verify that it is read/write for your profile.
Any further hints?
did you check if you are able to add the account team member and edit the access to read/write from UI?
Yes. I can log in as the API user and do it from the UI with no problem. Thanks.
Finally! Creating the AccountShare object was the real key. My errors after implementing that occurred because I was trying to set AccountShare.RowCause = "Team", which is not allowed from the API and not necessary, and I was not setting AccountShare.OpportunityAccessLevel, which is required. My working code is below.
Thanks for all the help!
AccountTeamMember newAccountTeamMember = new AccountTeamMember();
// Cannot set AccountAccessLevel here-- not allowed with the API. Defaults to "Read"
newAccountTeamMember.AccountId = accountId;
newAccountTeamMember.TeamMemberRole = userAccountTeamMembers[i].TeamMemberRole;
newAccountTeamMember.UserId = userAccountTeamMembers[i].UserId;
newAccountTeamMembers[i] = newAccountTeamMember;
//Should not set AccountShare for the owner but for others
if (userAccountTeamMembers[i].UserId != account.OwnerId)
{
AccountShare newAccountShare = new AccountShare();
newAccountShare.AccountAccessLevel = "Edit";
newAccountShare.AccountId = accountId;
newAccountShare.OpportunityAccessLevel = "Read";
newAccountShare.UserOrGroupId = userAccountTeamMembers[i].UserId;
newAccountShares[i] = newAccountShare;
}
Exeter,
Is it possible to see more of your code. I am new to this and trying to determine where/how userAccountTeamMembers[i] is generate.
Thanks!