Skip to main content
added 18 characters in body
Source Link
arnaud
  • 106
  • 1
  • 10

The error System.LimitException: Too many SOQL queries: 101 is because you cant have more of 100 SOQL query (Synchronous limit)

(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)

List<Contact> contacts = [
    SELECT Id, FirstName, LastName, Email, AccountId
    FROM Contact
    WHERE (Email = null OR Email = '')
    LIMIT 742
];

List<User> usersToDisable = [select id, isActive from User where ContactId in :contacts];contacts and isActive=true];
for (User u : usersToDisable) {
  u.isActive= false;
}
update usersToDisable;

delete contacts;

The error System.LimitException: Too many SOQL queries: 101 is because you cant have more of 100 SOQL query (Synchronous limit)

(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)

List<Contact> contacts = [
    SELECT Id, FirstName, LastName, Email, AccountId
    FROM Contact
    WHERE (Email = null OR Email = '')
    LIMIT 742
];

List<User> usersToDisable = [select id, isActive from User where ContactId in :contacts];
for (User u : usersToDisable) {
  u.isActive= false;
}
update usersToDisable;

delete contacts;

The error System.LimitException: Too many SOQL queries: 101 is because you cant have more of 100 SOQL query (Synchronous limit)

(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)

List<Contact> contacts = [
    SELECT Id, FirstName, LastName, Email, AccountId
    FROM Contact
    WHERE (Email = null OR Email = '')
    LIMIT 742
];

List<User> usersToDisable = [select id, isActive from User where ContactId in :contacts and isActive=true];
for (User u : usersToDisable) {
  u.isActive= false;
}
update usersToDisable;

delete contacts;
Source Link
arnaud
  • 106
  • 1
  • 10

The error System.LimitException: Too many SOQL queries: 101 is because you cant have more of 100 SOQL query (Synchronous limit)

(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)

List<Contact> contacts = [
    SELECT Id, FirstName, LastName, Email, AccountId
    FROM Contact
    WHERE (Email = null OR Email = '')
    LIMIT 742
];

List<User> usersToDisable = [select id, isActive from User where ContactId in :contacts];
for (User u : usersToDisable) {
  u.isActive= false;
}
update usersToDisable;

delete contacts;