2

I am trying to debug below trigger:

trigger SendEmailToHiringManger on SFDC_Job_Opening__c (after insert, after update) {

    list<SFDC_Job_Opening__c> i = [select id,Hiring_Manager__c,Name from SFDC_Job_Opening__c where id=:trigger.newMap.keySet()];

    system.debug('Name is'+ i.get(0).Hiring_Manager__c);

}

I have created a user trace flag in debug logs. I am expecting this trigger to execute when I edit and save a record of object SFDC_Job_Opening__c. However, I do not see the debug logs displayed in the debug log list. What is the reason for that? Is my trigger executing?

  • 1
    is your current user added in debug logs and also check the time selected for current user . – Ratan Paul Mar 29 '16 at 16:43
  • I added the debug log on user and I guess that worked. Earlier I was creating the track on the apex trigger itself. How does the two differ -track on User and apex trigger . – SfdcBat Mar 29 '16 at 17:01
  • 1
    Rdvm-- both are pretty much equal if you select user then it will generate user context debug logs and for apex class it will give that class debug (I am not sure in this point) – Ratan Paul Mar 29 '16 at 17:04
  • Ok thnks, I have two log type that shows up. 1 is DEVELOPER_LOG and other is USER_DEBUG. When I created the USER_DEBUG I was able to see the log but when I had DEVELOPER_LOG I did not see any logs. Not sure why. – SfdcBat Mar 29 '16 at 17:06
  • 1
    Rdvsm.. I suggest check few documentation for well explanation salesforce.stackexchange.com/questions/92771/… and help.salesforce.com/apex/… .. You will get all answer :) – Ratan Paul Mar 29 '16 at 17:09
1

When you use the Change Log Levels section in the developer console, you are essentially creating TraceFlag records. See Customize Your Trace Flags and Debug Levels in the Developer Console

The relevant part from the TraceFlag documentation:

LogType

When you open the Developer Console, it sets a DEVELOPER_LOG trace flag to log your activities. USER_DEBUG trace flags cause logging of an individual user’s activities. CLASS_TRACING trace flags override logging levels for Apex classes and triggers, but don’t generate logs.

That last part that I've made bold is the important part. A class/trigger LogType that the "Class and Trigger Trace Overrides" section creates won't cause the logging to be captured. It will just change the level that gets collected for those individual classes and triggers.

Instead you need to either create a "General Trace Settings for You" or a "User Tracing for All Users" entry with an Expiration in the future.

  • I was about to post a similar question but I think I now understand how class_tracing flags fit in. In my case, I only want to see the logs for one specific class (a registration handler for openID connect). So if I setup a user_debug trace flag for myself at a logging level of none/none/none/... and setup a class_tracing flag on the one class I'm interested in w/ appropriate logging levels, I should be able to just capture logs on the class I'm interested in. Is that correct? – gorav Mar 5 '17 at 2:49
  • @gorav, yes, that sounds reasonable. If it doesn't work, try giving at least one of the User levels ERROR rather than NONE. – Daniel Ballinger Mar 5 '17 at 20:59
0

Can you chnage your query like this and try,

select id,Hiring_Manager__c,Name from SFDC_Job_Opening__c 
 where id IN:trigger.newMap.keySet()
  • issue was in debug log he didn't added the current user – Ratan Paul Mar 29 '16 at 17:05
  • It works with my original syntax too! – SfdcBat Mar 29 '16 at 17:07
0

Maybe the problem is that the event is not invoked, could you try something like this:

 trigger SendEmailToHiringManger on SFDC_Job_Opening__c (after insert, after update) {

    for( SFDC_Job_Opening__c s : Trigger.new())
    {

        system.debug('Name is'+ s.Hiring_Manager__c);

    }
 }
  • I guess it should be for( SFDC_Job_Opening__c s : i){ }. But I am unable to see the logs yet. I created a new trace flag on the trigger and created a new debug level. – SfdcBat Mar 29 '16 at 16:51
  • I guess it works without a for loop too. – SfdcBat Mar 29 '16 at 17:03
  • 1
    issue was in debug log he didn't added the current user – Ratan Paul Mar 29 '16 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.