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
hoomelhoomel 

License limit exceeded on User trigger

Hi,

 

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 = Trigger.new;
	private User[] oldUser;
	if(Trigger.isUpdate){oldUser = Trigger.old;
		if(oldUser[0].isActive == false && newUser[0].isActive == true){
			newUser[0].Last_Inactive__c = System.now();
		}
		if(oldUser[0].isActive == true && newUser[0].isActive == false){
			newUser[0].Last_Active__c = System.now();
		}
	}
	if(Trigger.isInsert){newUser[0].Last_Inactive__c = System.now();}
}

 Thanks for the help in advance,

 

Regards,

hoomel

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

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...

souvik9086souvik9086

Hi,

 

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.

 

Thanks

hoomelhoomel

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?