The URL hack has been a special “secret” for admins for years. It’s great for creating a custom button or link to help our users fill out data. I’ve used the URL hack for three primary purposes:
- Create a related record and pre-fill fields.
- Link to a report with dynamic filters.
- Pre-select email template and recipients (custom “Send an Email”).
With Chatter Publisher Actions, we no longer need a URL hack for creating new records. A custom action might be able to handle the other two use cases, but I’ll save that for the developers. There are fantastic reasons to use a Chatter Publisher Action instead of a URL hack:
- It’s easier to create
- It’s available in mobile (Salesforce1)
- Officially supported by Salesforce.com (URL hacks are not)
- Can be deployed – even when using new custom fields
***Updated 1/9/2014 — I was reminded that I forgot a really good reason to use a Publisher Action instead of a URL Hack:
— Shannon Hale (@shannonsans) January 9, 2014
First, let’s review what it takes to do a URL hack.
- Identify the fields you want to populate
- Identify the HTML names for each field
- Create a custom button/link by modify/adding parameters
- Build the URL
I’m not going to go into details of how to build a custom button URL hack. Let me know in the comments if you want a “How to” on URL hacks. Otherwise, here’s some other posts:
- http://raydehler.com/cloud/clod/salesforce-url-hacking-to-prepopulate-fields-on-a-standard-page-layout.html by Ray Dehler
- http://writeforce.blogspot.com/2013/01/prepopulating-fields-using-url-hacking.html by Saurabh Dhoble
- http://amberneill.wordpress.com/2012/02/20/taking-ownership-leads-cases/ by Amber Neill
Creating the actual URL can be fairly easy and simple, especially if you’re just dealing with a couple of fields. More than a couple of fields the URL can get long and messy. Plus there’s no guarantee that a custom field ID will be the same on production unless you refreshed after it was deployed. That makes URL hacking messy. Enter – the Chatter Publisher Action!
Here’s the scenario.
I have a custom object related to Accounts and Opportunities called “Sales Strategies.” The record will always be created from the Opportunity. I want a user to be able to click and enter a new Sales Strategy that’s already tied to the Account and Opportunity.
Before we begin, make sure you have Publisher Actions enabled. The setting can be found under your Chatter Settings.
Let’s create a Chatter Publisher Action:
- Go to the “Buttons, Links, and Actions” Menu option under Opportunities.
- Click “New Action” & fill out details.
- Add fields to be on the Action Layout.
- Set Pre-defined Values. Here’s where we can set the Account name by grabbing the Account from the Opportunity.
- Add to the Opportunity page layout.
And we’re done! Here’s what it looks like on the page:
And the result when we hit create:
Chatter Publisher Actions are fantastic. They are very easy to update. You don’t need to grab IDs. You don’t need to worry about missing a character or spaces in the URL. Plus you can use the standard Salesforce formula builder. Want to have the name be defaulted to a combination of the Account Name and Close Date? No problem! Just set a new pre-defined field.
Our Sales Strategy Name is magically defaulted:
The URL Hack still has great use cases. My favorite use case is pre-selecting an email template and recipients for “send an email.” Let me know if you’re interested in the comments and maybe that’ll be a future post. I’ll love to hear what you’ve used Chatter Publisher Actions for. Post in your Chatter Actions in the comments!
I’ll leave you with some screenshots of what our publisher action looks like in Salesforce1. I didn’t have to do anything extra to get this to be available. It’s simply there. You can test out your own publisher actions in Salesforce1 using a compatible browser (like Chrome) and going to /one/one.app — for example: https://NA9.salesforce.com/one/one.app