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

Reverting the user email from .invalid after refresh
When sandboxes refresh, all users' email addresses have .invalid appended to them.
I am trying to revert all System Admin user emails to the correct one.
List<User> UserList = [SELECT id, email FROM User WHERE Profile.name = 'System Administrator' AND IsActive = True];
System.debug('Orginal List --->'+UserList);
for(User obj : UserList){
obj.Email = obj.Email.removeEndIgnoreCase('.invalid');
System.debug('email==>'+obj.Email);
}
if(UserList!= NULL && UserList.size() > 0)
{
List<Database.SaveResult> SR = Database.update(UserList);
for(Database.SaveResult srObj : SR){
System.debug(srObj);
}
System.debug('Final User List ==>'+UserList);
}
While implementing this code from an anonymous block, I can see the changes in my debug log, though the users' email is not changed.
Can some expert guide me where I am going wrong
I am trying to revert all System Admin user emails to the correct one.
List<User> UserList = [SELECT id, email FROM User WHERE Profile.name = 'System Administrator' AND IsActive = True];
System.debug('Orginal List --->'+UserList);
for(User obj : UserList){
obj.Email = obj.Email.removeEndIgnoreCase('.invalid');
System.debug('email==>'+obj.Email);
}
if(UserList!= NULL && UserList.size() > 0)
{
List<Database.SaveResult> SR = Database.update(UserList);
for(Database.SaveResult srObj : SR){
System.debug(srObj);
}
System.debug('Final User List ==>'+UserList);
}
While implementing this code from an anonymous block, I can see the changes in my debug log, though the users' email is not changed.
Can some expert guide me where I am going wrong