You need to sign in to do that
Don't have an account?
HOW ASSIGN CASE TO A USER HAVING MINIMUM NUMBER OF CASES
Whenever a new case is created, Assign case to most free user (who have minimum no of cases). There is a counter on user which show that how many cases has been assigned to an user. Based on this counter cases will be assigned to users....
i am doing like this but not able to...
Assigned_Cases__c is a custon field on user...
trigger assignUser on Case (before insert,after insert)
{
String userId = '';
Map<id,user> userMap= new Map<id,user>([select id, Assigned_Cases__c from User]);
if(Trigger.isInsert && Trigger.isBefore)
{
for(case c : Trigger.new)n
{
List<User> uu = userMap.values();
List<id> i =[select id from uu ORDER BY uu.Assign_Case__c ASC];
userId = i[0].id;
user up = userMap.get(userid);
up.Assign_Case__c++;
userMap.put(userId,up);
c.ownerId = userId;
}
update userMap.values();
}
}
ERROR:-Error: Compile Error: sObject type 'uu' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. at line 12 column 41
SOQL is not allowed on Collection. You are trying to query LIST.
Please try below code.
hi..
its not working fine...
error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger assignUser caused an unexpected exception, contact your administrator: assignUser: execution of BeforeInsert caused by: System.StringException: Invalid id: : Trigger.assignUser: line 13, column 1