You need to sign in to do that
Don't have an account?

while compiling the class i am getting folowing errors.
I am getting following errors in below code
Field is not writeable: AccountShare.AccountAccessLevel
Field is not writeable: AccountShare.CaseAccessLevel
Field is not writeable: AccountShare.OpportunityAccessLevel
Field is not writeable: AccountShare.AccountId
Field is not writeable: AccountShare.UserOrGroupId
if(z==0 && resgroup.get(asset.Reseller__c)!=null){
Accountshare ashare = new AccountShare();
ashare.AccountAccessLevel='Edit';
ashare.CaseAccessLevel='None';
ashare.OpportunityAccessLevel='None';
ashare.AccountId=asset.AccountId;
ashare.userOrGroupId=resgroup.get(asset.Reseller__c);
newshares.add(ashare);
}
Field is not writeable: AccountShare.AccountAccessLevel
Field is not writeable: AccountShare.CaseAccessLevel
Field is not writeable: AccountShare.OpportunityAccessLevel
Field is not writeable: AccountShare.AccountId
Field is not writeable: AccountShare.UserOrGroupId
if(z==0 && resgroup.get(asset.Reseller__c)!=null){
Accountshare ashare = new AccountShare();
ashare.AccountAccessLevel='Edit';
ashare.CaseAccessLevel='None';
ashare.OpportunityAccessLevel='None';
ashare.AccountId=asset.AccountId;
ashare.userOrGroupId=resgroup.get(asset.Reseller__c);
newshares.add(ashare);
}
Refer below thread for similar discussion.
https://salesforce.stackexchange.com/questions/192936/how-to-fix-field-is-not-writeable-error
Best Regards,
Sandhya
List<Accountshare> newashares = new AccountShare();
if(z==0 && resgroup.get(asset.Reseller__c)!=null){
ashare.AccountAccessLevel='Edit';
ashare.CaseAccessLevel='None';
ashare.OpportunityAccessLevel='None';
ashare.AccountId=asset.AccountId;
ashare.userOrGroupId=resgroup.get(asset.Reseller__c);
newshares.add(ashare);
}
update newshares;
Thanks,
Narendar
Please check your field level access for those fields. If it is read only in profile level you cannot update or edit fields through class.
Thanks
Guru Vemuru