Skip to content

Instantly share code, notes, and snippets.

@xjsender
Created September 19, 2017 03:31
Show Gist options
  • Select an option

  • Save xjsender/e95e75054d22ef89004c2be37d1291aa to your computer and use it in GitHub Desktop.

Select an option

Save xjsender/e95e75054d22ef89004c2be37d1291aa to your computer and use it in GitHub Desktop.
User Problem
List<Contact> cons = [
SELECT Id, Name FROM Contact
WHERE Role_Id__c != null
AND Is_Active__c = true
AND Email != null
];
List<User> users = [
SELECT Id, ContactId FROM User WHERE ContactId IN :cons
];
Map<Id, User> usermap = new Map<Id, User>();
for (User usr : users) {
usermap.put(usr.ContactId, usr);
}
for (Contact con : cons) {
if (!usermap.containsKey(con.Id)) {
System.debug(LoggingLevel.INFO, '*** con.Name: ' + con.Name);
System.debug(LoggingLevel.INFO, '*** con.Id: ' + con.Id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment