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
bblaybblay 

Make Authenticated Website User Inactive

In order to free up licenses easily I want to allow Authenticated Website users to make their account inactive so I don't have to personally uncheck the 'Active' box on their User information page.

 

Below is some code I thought would work perfectly and make things very easy without having to create a customer controller until I got the error "Error: Cannot de-activate self" 

 

 

<apex:page standardStylesheets="false" sidebar="false"  standardController="User" showHeader="false"  >

Name: {!User.firstname}

<apex:form >

UNCHECK to make account inactive. <apex:inputField value="{!User.isactive}"/>

<apex:commandButton value="Finish Deletion" action="{!quicksave}"/>

</apex:form>

</apex:page>

 

Does anyone know of a simple way around this? Thanks!

 

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma

Here is my thought:

 

You can create a workflow and can define a time dependent action in that.

Like : Field Update after 10 mins.

So from the UI, Update any custom field and trigger the workflow and do the logout. After 10 minute workflow will be triggered and will update the ISActive field.

All Answers

Bhawani SharmaBhawani Sharma

This error is because , you are logged in with the same user and you are trying to deactivate the same. How it would be possible that you are deactivating yourself and still want to logged in into the salesforce.

bblaybblay

A very good point! I guess what  I'm wanting is for the user to somehow deactivate his or herself and then not be able to login again so essentially removing themself from my system after clicking the "Finish Deletion" button. If someone is to delete their account (become inactive)  they will not be logging in again into my system.

 

Guess I have some thinking to do...

Bhawani SharmaBhawani Sharma

Here is my thought:

 

You can create a workflow and can define a time dependent action in that.

Like : Field Update after 10 mins.

So from the UI, Update any custom field and trigger the workflow and do the logout. After 10 minute workflow will be triggered and will update the ISActive field.

This was selected as the best answer
bblaybblay

Brilliant idea! That'll do exactly what I need and isn't overly complicated at all.

 

Thanks!