You need to sign in to do that
Don't have an account?
shaan85
Avoiding governor limits for query using user methods.
Hi,
I am retrieving id of a user using user method.And using the same in retrieving the details.
But a gov limit exception is thrown in soql query.
Here is my code....
how can we avoid governor limit for this....
I have tried applying Limit and also making use of set ...
trigger Test on Lead (before insert,before update)
{
Lead [] lead_new = Trigger.new;
Lead [] lead_old = Trigger.old;
Set<Id> newLead = new Set<Id>();
public id id1;
public id id2;
private User varuser;
id1 = userinfo.getProfileId();
id2 = userinfo.getUserId();
varuser =[Select IsActive , Name from User where Id= :id2];
System.debug('UserName ' + varuser.name);
for (Integer k = 0; k <lead_new.size(); k++)
{
// Updation Takes place..
}
}
You can use functions like Limits.getDMLRows() and Limits.getDMLStatements(). These functions will let you know the actual rows and DML statements used in your code. You can compare the result with the actual governor limits and handle the code.
Hope this helps.