function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert Wambold 10Robert Wambold 10 

Updating User object when UserLogin.IsFrozen is changed. Is it possible?

Hello all,

Is it possible to update a custom field (User_IsFrozen__c) on the User object when the Freeze / UnFreeze button is clicked?

Originally I was thinking an Apex Trigger or Process Builder could be used however UserLogin will not allow this.

So, what options are possible? Create custom buttons to Update UserLogin.IsFrozen and User.User_IsFrozen__c.

Any suggestions?

Thanks,

Robert

 

 

AbhishekAbhishek (Salesforce Developers) 
It looks like Bob Buzzard has blogged about a way to work around not being able to set the field via apex, take a look at the full blog post here (http://bobbuzzard.blogspot.com/2013/11/freezing-users-from-visualforce.html):

After digging through the Apex Developer’s Guide and experimenting with the execute anonymous element of the developer console it quickly became clear that I couldn’t freeze a user in Apex. Searching the SOAP API Developer’s Guide proved more productive when I came across the UserLogin object and its associated IsFrozen field. While this still means that I couldn’t use Apex, the SOAP API is accessible via the Ajax Toolkit which I can use from a Visualforce page.

It was then short work to create The Freezer - a Visualforce page to output all usernames present in the system and allow them to be frozen/defrosted at the click of a button. The page is shown below:

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.