Welcome

Standard

Welcome to my site. My name is Bill Greenhaw. I am a salesforce.com geek and MVP.

I am not the greatest writer around. Not even close. But hopefully you will enjoy what you do read, maybe laugh a bit, and hopefully learn something along the way.

Some say I think outside of the box but I don’t like thinking there is even a box to think outside of. In my mind only a solution exists. This might not fit with some people’s business philosophy  and I understand this. My mind works this way, though, and this is how I will write here.

I am completely transparent on this site. I don’t try to hide anything. I don’t try to play any games. I am who I am and it is that simple.

Sarcasm might be used often on the site.

If you have anything you would like me to write about contact me. My services are also available, even though the amount of time might be limited.

DFGuide.com – The must bookmark website for Dreamforce ’13

Standard

Last year I kept posting every party/event I came across. I somewhat did this year. But I am going to stop posting all the party info. The reason is the great folks at Arrowpointe, creators of Geopointe, have a better solution for everyone.

Go to DFGuide.com and bookmark this immediately. You especially need this on your mobile phone. They have all the parties listed and add new ones as soon as they are announced. DFGuide also gives you information on everything around the conference, from restaurants to parks to attractions.

Don’t be afraid of a little Apex

Standard

EDITED ON 8/6/14: Fixed some of the examples and added some content

In an earlier post I wrote about Workbench and how it can be utilized. Now I want to show you a way to use Apex inside workbench to do deletes or updates very quickly.

Many admins get scared and run away when they hear Apex. I am all for less code and more clicks (meaning use salesforce.com functionality instead of Apex when you can). But some Apex is easy and can help you quickly do things. Workbench allows you to execute Apex without a Visualforce page or calling a trigger.

Executing Apex within Workbench allows you to quickly update or delete data. This is one of the few things that Apex execution can help the average admin with. So I am going to show you how to do these two things and add a bit more to your arsenal.

When executing Apex in this fashion it is called Anonymous Apex. This is because with Anonymous Apex you do not need to deploy any code, you can simply run Apex immediately. Normally with Apex you need to write a class or classes, then a trigger, and then a test case. With Anonymous Apex you simply immediately execute your code. This is handy for quick data tasks, as you will see below. For those that have a database background you will really like Anonymous Apex.

NOTE: Please use Sandbox or Developer Edition when playing with any of these. You can easily delete or change data. VERY VERY VERY important that you always test things in Sandbox or Developer Edition first.

Mass deleting records using Apex:

Go to Workbench (if you need help on this first read up on my write-up about Workbench). Go to Queries–>SOQL Query. Choose your object, click on the ID field, and do any filtering you need. You want to choose records you will be deleting. Below is the example query I will work with.

SELECT Id FROM Account WHERE Type = ‘Big Bank’

Once you are good with the results of the query copy the query it and then head over to Utilities–>Apex Execute.  We will now write the Apex code to delete all the records returned from your query. For my example I am going to delete all accounts that have a type of Big Bank. Don’t be scared. This won’t be as hard as you think it will be.

List BigBanks = [SELECT Id FROM Account WHERE Type = ‘Big Bank’];
delete BigBanks;

That is it. The scariest part is just how easy it was to delete all those records. And you should be scared of that part, just not the Apex code. Use delete in Apex with caution simply because you can mass delete things so easily. This is why Sandbox or Developer Edition is important. Always test in one of those first.

To explain the code in short:

  • List<Account> simply means we are making a list of records. Think of it in those terms.
    • After List you must always put the object, which in this case is Account. This also needs to be surrounded by < >, so it is List
  • BigBanks is simply giving the list a name for reference. Name it whatever you want, just no spaces.
  • The next part is your SOQL query you copied. You can add more filters, if needed.
  • The last step simply says delete the name of your list (2nd bullet in this list).
  • Sometimes your query might return more than 10,000 records. A few ways you can deal with this but since we are going with simplicity the easiest way is to use LIMIT in your query.
    • At the end of your select statement you can add LIMIT 10000.

So not that hard, right?

Mass Updating Records

You can also mass update records using this same Apex Execute. In this example I will  show you how to change all contacts with a last name of Jones to Smith. Not sure why you would ever mass update everyone’s last name from Jones to Smith but it an example that you can hopefully understand.

Again go to Queries–>SOQL Query in Workbench.  Copy and paste the following query. Run it. Do you have anyone with the last name of Jones? If so you will get some results. You can change the filter, if you want, to something more relevant.

SELECT Id FROM Contact WHERE LastName = ‘Jones’

Once you are happy with the results of your query copy it.

Now like the delete example go to Utilities–>Apex Execute . Copy and paste the following code. Change the query, if you want.

List cnts = [SELECT Id FROM Contact WHERE LastName = ‘Jones’];
for(Contact c : cnts){
c.LastName = ‘Smith’;
}
update cnts;

Another simple one when you see it. This simply is going to update all contacts with a last name of Jones and change the last name to Smith.

Lets explain the different parts.

  • List is the same as the explanation in deletes. Making a list of all the contacts you will want to update.
  • cnts is the name of the list of contacts.
  • For basically loops through the list for you. Without the For it would not go through each record from the list.
  • Contact c : cnt is setting things up for the update. Contact c is saying we will be using the Contact object and c is name we will reference. c could have been anything, just name is c for short for Contact.
  • c.LastName is the field you will update. You can update any field that is updatable on the object. The c. is what says use the Contact object (see bullet above) and then you reference the field name, in this case LastName.
  • Lastly you simply say update listname; . So in this case the list name, set at the beginning, is cnts. So this updates all the records.

Again not so scary.

Little Apex code like this can really speed up some of your admin duties without being a full Apex developer. Don’t be scared and try these things out in a Developer Edition instance first to learn. Just remember that anything you do with Anonymous Apex is immediate and no simple way to rollback. So always do exports before you do this in production.

More Dreamforce Parties Announced

Standard

More Dreamforce parties have been announced. I know more will be coming in the next week or so. Visit the links below and sign-up!

Also visit this link to see the different posts I have done about Dreamforce Parties.  Dreamforce Party list.

AppBash – Wednesday, November 20,  Evening. This one you don’t signup beforehand. For the Dreamforce vets this was Cloud Crawl in the past.  More info given out at Dreamforce Cloud Expo on this one.

Kick Off AppBash with Cloud Sperpas – Wednesday, November 20, 5:30-8:30pm. B Bar and Restaurant, 720 Howard St. RSVP on their site. Great way to start the long, multi-party Wednesday night.

Silverpop – Monday, November 18, 9pm. Ruby Skye, 420 Mason Street . Always a fantastic Dreamforce party with live music. This year Grace Potter and the Nocturnals will be playing. Make sure you RSVP early on this one.

More to come later.

Description or help in page layouts

Standard

A question asked often by salesforce.com administrators is if they can customize the page layout with labels being colored or adding anything business process help. You used to be able to add HTML to the labels but this was “fixed” by salesforce.com and no longer works (security issue, so right for salesforce.com to stop it). So no label colors. You can add help text on each field so users can hover of the field to get more info about it. This works most of the time but not all the time. Sometimes you need to write a larger process for people to follow/explain.

If you need to write a longer description or help on an objects page layout you have two choices.

  1. Use Flows (Visual Workflow)
  2. Place a Visualforce page inside your page layout

Flows work sometimes and are great. Still trying to pick up steam with the salesforce.com community. You can create wizards, per say, that will walk users through  a business process. You can add info on Flows to help the users through the process.

Flows are not always the answer, though. Sometimes you just want to give some clear direction on one object to your users. Or maybe you want to explain some new fields you added to the page layout. This is where embedded Visualforce pages work well.

Do not get scared thinking you will need to be an Apex developer to do what I will show. It is a little helpful if you knew some HTML but that isn’t even necessary. The steps I am going to show are easy to follow and you don’t need to be a developer to do them.

For this tutorial we are going to write a Visualforce page explaining new fields we are adding to the Account page layout. The new fields are adding that haven’t previously been on the page layout is personal information including birthday, spouse name, date started at account, hobbies, do they like to talk personal on the phone (checkbox), and additional info. I have added Visualforce pages like this a few times, as I feel it helps users understand what you are doing as an administrator. You can remove the Visualforce page after a certain amount of time, if you want. I think by the end of this you will understand what I am meaning.

So here are the steps.

  1. You have created the new personal information fields but not added them to your page layout yet. You want users to understand why are we adding these fields, how they are used, and how they should be used.
  2. We want to write out the help/description and be able to get have it in HTML format.
    1. Go to Quackit’s HTML editor – http://www.quackit.com/html/online-html-editor/
    2. Type in whatever description/help you want. Here is an example.
    3. You now want to copy the actual HTML.
      1. Click the Source button
      2. Copy everything after <body> up to </body>
  3. Now head over to salesforce.com. I would use a new tab and keep the HTML editor tab in your browser.
  4. In salesforce.com go to Setup–>Develop–>Pages
    1. Click New
    2. Name the label whatever you want. In this scenario I am name it “Personal Information Description”
    3. Go down to the Visualforce Markup text area field.
    4. Delete everything in between <apex:page> and </apex:page>
    5. After <apex:page> paste in the HTML you copied earlier.
      1. Might look something like this:
    6. Click Save
  5. Now go to your contact page layout:  Setup–>Customize–>Contacts–>Page Layouts
    1. Edit one of your page layouts
    2. We want to add the Visualforce page to the page layout either at top or near the new fields.
      1. Drag the Section label somewhere into your page layout. This will hold the Visualforce page.
      2. Name the section whatever you want. I usually then uncheck the Detail and Edit page buttons, as I don’t want the section name showing up.
      3. Choose One Column
      4. Click Ok
      5. Now you want to drag the Visualforce page into the new section
        1. Towards the top click on Visualforce Pages
        2. Find your new Visualforce page and drag/drop it into your new section
        3. Move your mouse over the new blue area you see and click the wrench (on the right of the blue area)
        4. Change the height to something like 50. You can play with this until you get it the size you like.
      6. Save your page layout
  6. Now go to a contact that uses this page layout. You should see your Visualforce page inside the layout!

I hope you can now see how you can add  help or descriptions easily on page layouts using Visualforce pages, all without any development.

Have fun with this and help your users at the same time.

 

EDIT: Thank you to Deepak K. Anand for adding his thoughts to this. You should start your Visualforce page with ObjectName“>. This will allow it to also show up on the edit page. If you leave out standardController then the Visualforce won’t show up on the edit. So you have a choice on if you want or do not want this to show up when someone edits.