My new best friend

I’d like to introduce you all to my new best friend. He saves me so much time when needing to get past page layout issues, he’s extremely fast at making little data fixes and he’s amazing at debugging code. I like to call him Sy, but his full name System Log and he’s available to you at the top of your salesforce.com screens.

Here’s an example of how the System Log just saved me some time:
A client asked us to load some test data into their sandbox, but when we loaded the data, we didn’t set the owner, so all the data was owned by our user. Normally to fix this, we would open excel, login with the Excel Connector, query the table, update the rows in Excel and the use the connector’s update function. (We could also use the data loader, but for simple stuff like this, the Excel Connector is often faster.) It’s really not complex or that time-consuming, but opening up Excel always seems like a chore, and dealing with security tokens is a pain. I was already logged into their org in Firefox, why should I have to login again! So, instead, I opened up the System Log, typed in the below apex code and executed it. Instant fix!

List cons = [Select Id from contact where OwnerId != 'INSERT CORRECT ID' limit 999];
for (contact c : cons)
{
c.OwnerId = 'INSERT CORRECT ID';
}
update cons;

Please note that we don’t recommend doing this in your production org as you could ruin a lot of data very quickly. But, there are so many times where we need to just make a minor update like this, or create a new record without filling out fields required by the page layout when this functionality is a huge time saver.

The System Log is even better when trying to figure out why Apex code is not doing what you want it to. Just open it up and take an action which will trigger the code and the System Log will show you everything that is going on behind the scenes. You may want to adjust the Log Level to a level closer to Finest to see more information.

For those of you that work in Eclipse a lot, you can use the System Log there too. It’s available from the Execute Anonymous view. It saved me so much time today that I was able to write this post!

  • Share/Bookmark

Related posts:

  1. So many DML rows, so few DML statements
  2. Custom Views on the Home Tab
  3. Tracking the duration of a call
  4. Composite Application Case Study
  5. Spring cleaning old integrations

2 Comments to “My new best friend”

  1. John R (The Enforcer)No Gravatar Says:

    Ha! I just had to do a mass delete of a custom object and this method worked very nicely — substituting ‘delete’ in place of an ‘update’.

    Thanks for your timely tip!

  2. » Mass Delete via System Log window (The Enforcer.net, a force.com blog) Says:

    [...] I remembered a post I had read that morning from MK Partners about using the Salesforce System Log window to mass-update some data. Matt had written some quick Apex that executes in the System Log window. So, I modified it to do a [...]

Post a Comment