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

ContactShare doesn`t work
The user does not see the contact when adding the ContactShare
Code in Trigger:
User user = [SELECT Id FROM User WHERE Alias = 'mmana']; Contact contact = [SELECT Id FROM Contact LIMIT 1]; ContactShare contactShare = new ContactShare();
contactShare.Contact = contact;
contactShare.ContactId = contact.Id;
contactShare.UserOrGroupId = user.Id; contactShare.ContactAccessLevel = 'Edit';
insert contactShare;
Organization-Wide Defaults
Account: Private
Contact: Private
How can i solve this problem with Apex?
Code in Trigger:
User user = [SELECT Id FROM User WHERE Alias = 'mmana']; Contact contact = [SELECT Id FROM Contact LIMIT 1]; ContactShare contactShare = new ContactShare();
contactShare.Contact = contact;
contactShare.ContactId = contact.Id;
contactShare.UserOrGroupId = user.Id; contactShare.ContactAccessLevel = 'Edit';
insert contactShare;
Organization-Wide Defaults
Account: Private
Contact: Private
How can i solve this problem with Apex?
Hello Ilarion Tokarskiy 10
Please try to associate account to the contact which you are inserting for sharing with other users because
Contacts may not be shared independently from Accounts, so Contact Sharing Rules are not applied (even if they are defined).
you can follow this link to get more info.
https://salesforce.stackexchange.com/questions/232644/contact-sharing-rules-no-account