You need to sign in to do that
Don't have an account?

Trigger Question
Ok so I was doing some research on triggers and found something called Trigger Context Variables. In there I found something called isExecuting. I was wondering if I put that in a if statement around all my trigger code with it only run if a user in my org makes a change that causes the trigger to fire. For example if I pull Leads from Data.com with the trigger code fire?
Sample Code:
Trigger TestTrigger on Lead (after insert){ if(Trigger.isExecuting){ // Trigger code } {
Your code looks sound - I'm curious as to why you're hitting a SOQL Governor Limit.
Can you throw in some System.Debug messages, pull up the trusty old System Log - and reproduce the issue? Even if Data.com is batching this stuff in - each batch would have its own set of Limits...
-Andy
All Answers
From looking at the documentation I believe the point of this method is that you can use it in apex code that's called by your trigger, but not contained within the trigger itself — allowing you to differentiate between the code being run by a trigger or by some other method.
Using it inside the trigger itself would appear to make no sense, as it would always return true, you couldn't have code in a trigger being run that hasn't been the result of that trigger being fired.
Alright thanks for the information. I guess I just misunderstood what I read. My Issue really is that when I pull a large amount of Leads from Data.com I hit a governor limit for SOQL queries. I have a trigger that fires everytime a lead is added into our org. Is there anyway to get specific user information without using a SOQL query? Or is there a better way to right my trigger code?
Apex Trigger:
Your code looks sound - I'm curious as to why you're hitting a SOQL Governor Limit.
Can you throw in some System.Debug messages, pull up the trusty old System Log - and reproduce the issue? Even if Data.com is batching this stuff in - each batch would have its own set of Limits...
-Andy
The only way that I can reproduce the issue is to make a list of objects and insert them one at a time in a for loop. If I insert then as a list it works fine. I'm not sure when the issue is.
Aaahhh - that would explain it. You have that SOQL query at the head of your trigger that would fire for each record if you inserted them one at a time through another method.
Could you use the UserInfo object in place of your SOQL query to get the user's ID - place that in a new field in the Tracking__c object - then based on that, you could use Formula fields to pull in the other information from the UserId.
-Andy
I was able to figure something out. I used work flow rules and field updates to put the correct data into the fields that needed user information. I am in the process of testing it right know and it seems to be working fine for the moment.
Excellent! Declarative is absolutely the way to go if you can do it. Nice work.
(shameless plug) If my comment above helped you get to that conclusion, mark it as a solution so others can benefit (/shameless plug)