You need to sign in to do that
Don't have an account?
Dritter
Exception Handling
We have a class that deactivate two sets of users: (1) our portal customers and (2) salesforce license users that haven't logged in in the past 90 days. The problem I'm facing is I keep running into exceptions when the license user is part of escalation rule on cases or in a workflow rule email alert. I looked at the following article, but I'm not exactly sure where to place the exception handling code: https://developer.salesforce.com/page/An_Introduction_to_Exception_Handling.
Can anyone help? Thanks!
List<User> users = [SELECT Email,Id,LastLoginDate FROM User WHERE (IsPortalEnabled = True AND IsActive = true and (lastLoginDate < :newDateTime OR lastLoginDate = null)) OR (IsPortalEnabled = false AND isActive = true AND lastLoginDate < :inactiveDateTime AND LastName != 'Site Guest User') limit 150];
soqlCount = soqlCount + 1;
if (users.isEmpty()) {
System.debug('No users found');
done = true;
} else {
System.debug (users.size() + ' user account(s) will be updated');
for(User u : users) {
u.isActive = false;
//System.debug(u.id + ' ' + u.email + ' will be deactivated' + u.lastLoginDate);
}
update users;
}
Can anyone help? Thanks!
List<User> users = [SELECT Email,Id,LastLoginDate FROM User WHERE (IsPortalEnabled = True AND IsActive = true and (lastLoginDate < :newDateTime OR lastLoginDate = null)) OR (IsPortalEnabled = false AND isActive = true AND lastLoginDate < :inactiveDateTime AND LastName != 'Site Guest User') limit 150];
soqlCount = soqlCount + 1;
if (users.isEmpty()) {
System.debug('No users found');
done = true;
} else {
System.debug (users.size() + ' user account(s) will be updated');
for(User u : users) {
u.isActive = false;
//System.debug(u.id + ' ' + u.email + ' will be deactivated' + u.lastLoginDate);
}
update users;
}
There are two viable solutions,
1. Deactivate all users that can be deactivated and leave the rest as is. For this you need to change this line, to this, 2. Deactivate all users that can be deactivated and freeze the rest. For this you need to change this line, To this,
--Akram
All Answers
There are two viable solutions,
1. Deactivate all users that can be deactivated and leave the rest as is. For this you need to change this line, to this, 2. Deactivate all users that can be deactivated and freeze the rest. For this you need to change this line, To this,
--Akram