public class DeactivateUser {
List<User>ulist= new List<User>();
public void deactiveuser(String Username){
for (User u:[Select id,UserName,IsActive from user where UserName=:Username]){
u.IsActive=false;
ulist.add(u);
}
update ulist;
}
}
You need to send the userName as the input for the method while calling as shown below.
DeactivateUser de= new DeactivateUser();
de.deactiveuser('assaample@gmail.com');
If this solution helps, Please mark it as best answer.
You can write the Apex class as below.
You need to send the userName as the input for the method while calling as shown below.
If this solution helps, Please mark it as best answer.
Thanks,