As you know, there is freeze user feature came up in latest release. We can freeze the user if we are not ready to deactivate it .

how can i freeze a User with code ? Can we report on the Freeze users ?

I could not find any field on user which shows whether a user is frozen or not .

  • 1
    What would be the use case for this functionality? Presumably, you're freezing a user because you intend to permanently deactivate them.
    – sfdcfox
    Sep 27, 2013 at 13:33
  • A user can be linked to other multiple records. To deactivate it we have to remove all the links whereas if a freezed user can be linked to other records. the functionality gives time to Admin to do all the impact analysis before deactivating the user. Sep 28, 2013 at 15:28
  • I know what freezing is. I meant, what would be the point of freezing a user through code instead of manually?
    – sfdcfox
    Sep 28, 2013 at 16:38
  • Yeah. I do know not the explanation here.But, this is the requirement. Could u pls me with How to make a report on the freeze user. Admin wants a report on who all are freeze user. Sep 29, 2013 at 10:36
  • 1
    As far as I can tell, what you're asking for is impossible. No documentation states that you can report or query frozen users, or toggle this flag through any API or Apex Code. The point of asking "why" is so that salesforce.com might run across this question, and want to know what business use case it might possibly have. Without any reason why, other than "because we want to", salesforce.com is likely not to deliver such a feature until they feel they have time, which might be never. You should find out why they want this.
    – sfdcfox
    Sep 29, 2013 at 16:35

6 Answers 6


the UserLogin SObject has an IsFrozen field, you can set this to true (from apex, api etc) to freeze a user. You can query this field from SOQL to determine who is frozen (and also who has a password lockout in effect), I haven't looked but i'd think you can do a regular report against this object as well.


I wasn't able to find a way to do this from regular Apex, but it is possible using the SOAP API. I've blogged a Visualforce solution that uses the Ajax toolkit to retrieve the frozen status of the users and provide buttons to freeze/unfreeze each user:



Here is some sample code that I used to this:

List<UserLogin> users = [SELECT IsFrozen,UserId FROM UserLogin WHERE UserId IN 
    (SELECT Id FROM User WHERE Profile.Name != 'System Administrator' 
    AND UserType = 'Standard' AND IsActive=True) 
    AND UserId != :UserInfo.getUserId()];
for (UserLogin ul : users) { ul.isFrozen = True; }

This is possible in two ways: 1) Using Dataloader 2) Scripts to execute in Developer console http://theblogreaders.com/users-freeze-unfreeze-salesforce-using-script/


You can do that with a few clicks with sfdx-hardis VsCode extension :)

enter image description here

You can see details in the following article


Disclaimer: I work in the company providing this open-source plugin


I did the following to accomplish this.

Created two fields on USER:

Type Field Name
Checkbox Freeze_User__c
Datetime Freeze_User_DateTime__c

I created a workflow rule to check the Freeze User field at specific datetime

User: Freeze User DateTimeNOT EQUAL TOnull
TimeBased Action:  0 Hours after Freeze User TimeDate -> Check Freeze_User__c

Then I created the following Methods:

public static void FreezeUser(List <User> listUsers, Map <ID, User> oldUserMap) {
    list <UserLogin> listUpdatetoFrozen = new list <UserLogin>();
    list <User> listFrozenUsers = new list<user>();
    set <string> setFrozenUserIds = new set <string>();
    for(User u : listUsers)
        if(u.Freeze_User__c != oldUserMap.get(u.Id).Freeze_user__c) //if frozen has changed
            if(u.Freeze_User__c = True)

            list <UserLogin> FrozenUsers = [SELECT ID, isFrozen FROM UserLogin WHERE UserID IN :setFrozenUserIds];        
            for(UserLogin ulog : FrozenUsers)
                string Id = ulog.Id;
                boolean FrozenStatus = True;
                listUpdatetoFrozen.add(UserUtility.FreezeUserUpdate(Id, FrozenStatus));
            update listUpdatetoFrozen;
public static UserLogin FreezeUserUpdate (string Id, Boolean FrozenStatus) {
    UserLogin ulog = new UserLogin();
    ulog.Id = Id;
    ulog.IsFrozen = FrozenStatus;
    return ulog;

Test Class

public class UserHandlerTest {
    public static void Method1() {
        list <User> listactiveUsers = [SELECT Id, Freeze_User__c FROM USER WHERE isActive = True AND Freeze_User__c = False LIMIT 200];
        list <User> listUpdateUser = new list <User>();

        for(User u : listActiveUsers)
            u.Freeze_User__c = True;
        update listUpdateUser;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .