Saturday, December 24, 2016

Logs Inspector for Salesforce Admin

What is Logs Inspector?  
Logs Inspector maybe famous for Salesforce developers, but not for admin. So what is Logs Inspector?  It is a context-sensitive execution viewer that shows the source of an operation, what triggered the operation, and what occurred afterward. Use this tool to inspect debug logs that include database events, Apex processing, workflow, and validation logic.

Where is this tool located? 
Logs Inspector is located under Developer Console. Only user with “View All Data” permissions have access to Developer Console, for complete permissions needed, see this document View Debug Logs.

If you aware of Debug Logs (navigate to Setup | Logs | Debug Logs), Logs Inspector will show the same log, but with more info.

Once you are in Developer Console, click Logs tab at bottom left.

The same with using Debug Logs, when you do a transaction in Salesforce, the logs will be captured here. If you go to Debug Logs after transaction, you will notice your name is auto added / renewed in the User Trace Flags with current date time.

What can Salesforce admin make the most of this tool? See screenshot below, pretty complex isn't it.

There are many panels here, you can switch on/off from Debug menu | View Log Panels... or use Perspective Manager to save and load preferred panels. There are six panels in total:
1. Stack Tree
2. Execution Stack
3. Execution Log
4. Source
5. Variables
6. Execution Overview

I am not going to explain each panel in this blog, or maybe as admin you are not so interested to know all, except Execution Log which is captured all logs and similar with debug logs, where you can find logs related to things that you are looking for, like field update, soql, etc.

I am personally interested with Execution Overview, there are four tabs in this panel, but as admin, I am most interested with Save Order and Timeline tab.

The Save Order tab displays a color-coded timeline of DML actions. For each DML action taken, save order elements are shown as boxcars in the timelinem click the box too see more details.

The box color are used to differentiate between elements:
  • Red = before trigger
  • Orange = after trigger
  • Green = Validation rule
  • Blue = Assignment rule
  • Purple = Workflow rule

From above screenshot, we can trace the order of execution when create a new Account. Let's analyze:
Apex Trigger
Execution start with "before" trigger. Because there are 2 active triggers, Salesforce will randomly fire a trigger, continue with the other trigger. There's why it is not recommended to have 2 active triggers in an object.
Trigger: AccountHandler2 execute "before insert"
Trigger: AccountHandler1 execute "before insert, before update"

Next, it will execute validation rules exist for that object.

In this workflow there is a field update to a field in Account.

Apex Trigger
Because of workflow above, it will trigger AccountHandler1 again because this trigger execute "before update"

The Timeline tab provides a visual representation of the time taken by each process. Select the Scale option that results in the most useful view.

From timeline bar above, we see Validation rules take longest time for this sample of DML action to an account.


No comments:

Post a Comment

Page-level ad