1
私は、SFDCの初心者の方が、統合については多少なりともですが、共有が発生する可能性のあるすべての方法を考慮に入れて、特定のユーザーと共有されている連絡先だけを照会できる方法はありますか?基本的には、ユーザーがプラットフォーム内で参照するのと同じ連絡先を参照してください。SFDC - 特定のユーザーと共有されているすべての連絡先を照会しますか?
私は、SFDCの初心者の方が、統合については多少なりともですが、共有が発生する可能性のあるすべての方法を考慮に入れて、特定のユーザーと共有されている連絡先だけを照会できる方法はありますか?基本的には、ユーザーがプラットフォーム内で参照するのと同じ連絡先を参照してください。SFDC - 特定のユーザーと共有されているすべての連絡先を照会しますか?
私はこれがあなたが探しているものだと思います。それぞれのステップが何をしているのかを説明するために、いくつかのインライン・コメントを追加しました。最終的な結果は、組織内の指定されたユーザーが読むことができるすべての連絡先でなければなりません。
// add a set with all the contact ids in your org
List<contact> contacts = new List<contact>([Select id from Contact]);
Set<ID> contactids = new Set<ID>();
for(Contact c : contacts)
contactids.add(c.id);
// using the user record access you can query all the recordsids and the level of access for a specified user
List<UserRecordAccess> ura = new List<UserRecordAccess>([SELECT RecordId, HasReadAccess, HasTransferAccess, MaxAccessLevel
FROM UserRecordAccess
WHERE UserId = 'theuserid'
AND RecordId in: contactids
]);
// unfortunatelly you cannot agregate your query on hasReadAccess=true so you'd need to add this step
Set<id> readaccessID = new Set<ID>();
for(UserRecordAccess ur : ura)
{
if(ur.HasReadAccess==true)
{
readaccessID.add(ur.RecordID);
}
}
// This is the list of all the Contacts that can be read by the specified user
List<Contact> readAccessContact = new List<Contact>([Select id, name from contact where id in: readaccessID]);
// show the results
system.debug(readAccessContact);