Trigger to capture Deactivation of User date

Sample Code:

trigger DeactivationDate on User (before update) {
    Map<Id, User> UserMap = trigger.oldMap;
   
    for(User U : trigger.new) {
        if(U.IsActive == false) {
            User Usr = UserMap.get(U.Id);
            if(Usr.IsActive == true) {
                U.Deactivation_Date__c = U.LastModifiedDate;
            }          
        }
    }
}

2 comments:

  1. How to display Account,contact information on Oppurtunity object using visualforce pages

    ReplyDelete
  2. Hi,
    I'm geting error as Invalid field Deactivation_Date__c for SObject User

    ReplyDelete