Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to create an Account Share Record?

Asked by Elonjigar May 12, 2023 1.5K views 1 answer
Share

About this question

 I have a requirement to create sharing records for accounts. But When i try to create AccountSHare record it gives me an error DML Operation not allowed.

Here is the code

String query =' Select Id FROM Account WHERE '+String.join(whereClause,'AND'); List accounts = Database.query(query) ; List share = new List(); for(Account a:accounts){ AccountShare accountShare = new AccountShare(); accountShare.AccountId = a.Id; accountShare.UserOrGroupId = groupId; accountShare.AccountAccessLevel = 'Edit'; accountShare.ContactAccessLevel = 'Edit'; accountShare.OpportunityAccessLevel = 'Edit'; share.add( accountShare); } insert share;
Any help?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.