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
manishymanishy 

Account Share with Inactive User

Can we insert an record in AccountShare Object with an reference to inactive user.?

Navatar_DbSupNavatar_DbSup

Hi,

 

 Yes you can insert the accountshare record. First of all you have to set the OWD is private for account and then create the public groups.

 User should be in the public group have the role below your user who is creating the record.

 

 Try the below code to create the account share:

 

 account acc=new account(name='checkaccountshare');

 insert acc;

 list<GroupMember> gp=[select id,UserOrGroupId  from GroupMember];

 AccountShare AccShare = new AccountShare(AccountId = acc.Id,AccountAccessLevel = 'Edit', OpportunityAccessLevel = 'Read',CaseAccessLevel = 'Read', UserOrGroupId = gp[0].UserOrGroupId  );

Insert AccShare;   

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

manishymanishy

Thanks for Reply,

No, I Still have an issue.

I agree that we have to insert AccountShare in that way. But my problem is that, i am trying to insert an reference to a user which is currently in inactive state. It throws an error in this case.