You need to sign in to do that
Don't have an account?
Too many soql queries
I am running into Too many SOQL queries error..
I know that there is soql inside for loop which is causing the problem.
How to change So that I cannot get "Too many SOQL queries"
public with sharing class Create_pass {
public list<user> usr;
public void create_password() {
List<User> userList = new List<User>();
userList = [SELECT Id,alias,Email,Territory_Id__c,Pass__c,title from User ];
for (User u : userList)
{
System.setPassword(u.Id,u.Territory_Id__c);
System.debug('DONE: '+ u.Id);
}
}
}
Couple of questions
1. How often do you call this class( create_password method) ?
2. Does it really need to go through all the users each run?
Try adding the where clause to the select. Only pick users without password, or even better only users you are working on right now
you might have enabled readOnly property of <apex:page> tag,which will block DML operations and gives the error "Too Many SOQL queries" even though your using one soql query.
so remove readonly from page tag and try
No Iam not using readonly property