You need to sign in to do that
Don't have an account?
Mohidheen N
EXCEPTION: System.LimitException: Too many SOQL queries: 101 STACKTRACE: AnonymousBlock: line 9, column 1
List<UserPackageLicense > llist = new List <UserPackageLicense > ([SELECT id,UserId FROM UserPackageLicense
where PackageLicenseId='05000000000000000']); //- 5000 records
system.debug(llist.size());
Map<ID,Datetime> C_U_map = new Map<ID,Datetime>();
for (UserPackageLicense Ulist: llist){
List<User> C_U_list = new List<User>([select id,LastLoginDate from User where User.id =:Ulist.UserId]);
C_U_map.put(Ulist.UserId,C_U_list[0].LastLoginDate);
system.debug(C_U_map);
C_U_map.clear();
}
Hi There,
I'm using the above AnonymousBlock and getting governer limits. If i'm using limit clause then code is working fine.
UserPackageLicense having 5000 records how can i retrieve without governer limits.
Can you please suggest?
where PackageLicenseId='05000000000000000']); //- 5000 records
system.debug(llist.size());
Map<ID,Datetime> C_U_map = new Map<ID,Datetime>();
for (UserPackageLicense Ulist: llist){
List<User> C_U_list = new List<User>([select id,LastLoginDate from User where User.id =:Ulist.UserId]);
C_U_map.put(Ulist.UserId,C_U_list[0].LastLoginDate);
system.debug(C_U_map);
C_U_map.clear();
}
Hi There,
I'm using the above AnonymousBlock and getting governer limits. If i'm using limit clause then code is working fine.
UserPackageLicense having 5000 records how can i retrieve without governer limits.
Can you please suggest?
Use a set to get the ids of user and then after for loop, apply query to get the required data.
All Answers
Use a set to get the ids of user and then after for loop, apply query to get the required data.
where PackageLicenseId='0500000000000000']);
system.debug(llist.size());
set<ID> Set_ID = new set<ID>();
for (UserPackageLicense Ulist:llist){
Set_ID.add(Ulist.UserId);
}
system.debug(Set_ID.size());
List<User> C_U_list = new List<User>([select id,name,LastLoginDate from User where User.id IN:Set_ID and LastLoginDate < LAST_N_DAYS:365]);
system.debug(C_U_list.size());
system.debug(C_U_list);