Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. trigger CommunityUserContactRemove on User (after update) {
  2.  
  3. Profile p = [SELECT Id FROM Profile WHERE Name = 'Quatro Community Login User'];
  4.  
  5. List<Contact> userContacts = new List<Contact>();
  6.  
  7. for (User u : trigger.new) {
  8. User oldUser = Trigger.oldMap.get(u.Id);
  9. if (string.isBlank(u.ContactId) & u.ProfileId == p.Id){
  10. userContacts.add(new Contact(
  11. Id = oldUser.ContactId,
  12. Support_Community_User__c = null));
  13. }
  14. }
  15.  
  16. update userContacts;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement