Display Only My Role’s Records on a Report

Making a Salesforce Opportunity leaderboard is possible, but I’ve seen some cases where the standard filters don’t work well enough. It is easy enough to make a report that shows “My Accounts,” “My Opportunities,” and others. Let’s look at some of the standard options: According to the documentation, My Opportunities - Searches ONLY the opportunities you OWN. My Team-selling opportunities - Searches ONLY the opportunities where you are on the SALES TEAM. My Team-selling and my own Opportunities - Searches BOTH the opportunities you OWN and the opportunities where you are on the SALES TEAM. My Team’s Opportunities - Searches ONLY the opportunities OWNED by you and the users who report to you in the role hierarchy. My Team’s Team-selling and their Opportunities - Searches the opportunities OWNED by you and the users that report to you in the role hierarchy, as well as opportunities where you or the users who report to you in […]

Chatter Publisher Actions (Part 2): Object Custom Action

Setup Actions

In the previous post, we looked at using the standard (button-click) way to create a new child record using Publisher Actions. Pretty basic stuff. Using Visualforce to create a custom action is a bit harder. Let's start with the documentation. The PDF provided by clicking on the link in the Actions screen (Account action is an example) has nothing about Visualforce. Searching in the Help & Training section yields a page Creating Visualforce Pages to Use as Custom Publisher Actions, but I can't see where that page is found in the help tree on the left side of the page. Interestingly, to find correct code (because the item above has a misprint) I had to go to Customizing Case Feed with Visualforce (PDF). Let's set up our use-case and see what we can do with a Visualforce publisher. As before, we want to create a Task from a Case. The […]

Chatter Publisher Actions (Part 1): Create a Record

Chatter Multi-Dimensional Publisher Logo

One of the most interesting – but least explained – features of Summer 13 (184) is Chatter Actions. There are three kinds of actions (Yes, you thought there were two, but there are more!) and after writing a few of each, here are some examples. The documentation is, as of this writing, both incomplete and incorrect, so this should help a bit. I also found some gotchas when using Chatter actions in a specific setting. Chatter Actions fall into two major categories: “Create a Record” and “Custom Action.” There are two locations for Chatter Actions: Object-specific and Global, meaning that Create actions and Custom actions can each be executed from a specific object Chatter publisher or can be created from the general publisher found on the Home and Chatter tabs. To review: Create action Global Object-specific Custom action Global Object-specific Clear, right? We could visualize it as first Object-specific, then […]

Create and Populate a Map<Id, Sobject> Without Loops

There are many reasons to use Maps in Apex triggers. Sometimes I want to make a List of Contacts, but I want to pull each one by its ID. This is a good reason to abandon the List and to make a Map<id, Contact>. (Some will prefer to use Map<string, Contact>, and that is okay too.) This is how I used to populate a Map<id , Contact> of all Contacts at Accounts in a trigger: This takes time and uses script statements, and in a big org/app, we want to minimize both. Here’s my new way: It’s pretty simple, and it works well. It also keeps code clean. More astute readers will note that this is similar to the Trigger context variables trigger.oldMap & trigger.newMap, which populate a map of the trigger records keyed to their record ids.