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
vikas rathi91vikas rathi91 

Field is not writeable: AccountShare.AccountId

User-added image

I try to solve but not find any solution 

how to solve it

Thanks In advance
Best Answer chosen by vikas rathi91
Pankaj MehraPankaj Mehra
hi Aaki,

First check is Account is private in your organisation then only you will get AccountShare object.

Some more limitation on this field:
You cannot update AccountId field on the AccountShare Object. To update a accountshare records and add new AccountId , You need to delete the existing AccountShare records and create new one.

 

All Answers

Vivek DVivek D
// TRY THIS

AccountaccShare accShare = new AccountaccShare();
accShare.setAccountId(rec.getId());
accShare.setUserOrGroupId(userId);
accShare.setAccountAccessLevel("Edit");
accShare.setOpportunityAccessLevel("Read");
accShare.setCaseAccessLevel("Edit");
accShares.add(accShare);

 
Pankaj MehraPankaj Mehra
hi Aaki,

First check is Account is private in your organisation then only you will get AccountShare object.

Some more limitation on this field:
You cannot update AccountId field on the AccountShare Object. To update a accountshare records and add new AccountId , You need to delete the existing AccountShare records and create new one.

 
This was selected as the best answer