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

License limit exceeded on User trigger



I created a trigger on the User object, to fill a field with the date on which the user was activated, respectively deactivated.


When a new user is created, the current date should also be put in a field. This especially causes a LICENSE_LIMIT_EXCEEDED.

Why exactly is this caused and how can I avoid it?


Here's the code:

trigger userTrigger on User (before update, before insert) {
	private User[] newUser =;
	private User[] oldUser;
	if(Trigger.isUpdate){oldUser = Trigger.old;
		if(oldUser[0].isActive == false && newUser[0].isActive == true){
			newUser[0].Last_Inactive__c =;
		if(oldUser[0].isActive == true && newUser[0].isActive == false){
			newUser[0].Last_Active__c =;
	if(Trigger.isInsert){newUser[0].Last_Inactive__c =;}

 Thanks for the help in advance,




Are you sure you have sufficient licenses to create new users ?

The user limit has reached its maximum, but shouldn't I be able to create a trigger on the object? Or does this trigger create a new user when activated?


Just to be clear, the error message does come up when trying to upload the trigger, not when creating a new User...




There is a limit for creating number of users. May be that limit is exceeded. That may be the reason of the error.


If this post solves your problem, kindly mark it as solution.




As most of the times, it always is a problem, when you do not read error message completely.

The error was not caused by the Trigger itself but within a test class, which is creating a test User to cover the User trigger.


Is the test User really counting towards the user limit? Can I test the trigger in another way?