I have written one class and inside that there is method which calling one small method ,what i need is to call inside method based on Insert and update
If Operation is INSERT then call one method if Operation is UPDATE then call other method.
how to get the context from trigger to class-method and check if its insert or update
public static void assignLicense(List<user> usr) {
//find the PackageLicense Id
if(pl.size()>0){
System.assert(pl != null, 'PackageLicense cannot be null.');
if(trigger.isinsert)
List<User> usersToAssignLicenses = getUsers(usr);
If(trigger.isupdate){
}
List<User> usersToAssignLicenses = getUsers2(usr);
}
static List<User> getUsers(list<user> usr){
List<User> matching= new List<User>();
Set<Id> Ids = new Set<Id>();
for(user u:usr) {
Ids.add(u.id);
}
matching = [SELECT Id FROM User WHERE id in:ids and profile.name='Internal User'];
return matching;
}
static List<User> getUsers2(list<user> usr){
List<User> matchingUsers = new List<User>();
Set<Id> Ids = new Set<Id>();
for(user u:usr) {
Ids.add(u.id);
}
matching = [SELECT Id FROM User WHERE id in:ids and profile.name='Sales User'];
return matching;
}