Reports Dynamically Filtered

Written by ShamrockCRM on August 9, 2009 – 3:16 pm

When using Campaigns for mass mailing, the easiest way to add a large amount of Contacts to the Campaign is to have a predefined Contact report. With this predefined Salesforce report, you can easily click the “Add to Campaign” button and automatically add all of the Contacts on the report to this Campaign. Reports

If you needed to step through this process to create or modify a report every time you needed to add a new set of users to a campaign, you would spend a lot of time setting this up.

Well, provides the capability to create a generic report that will have generic criteria established that can be dynamically filtered through the URL. For example, lets say you created a generic “Sales Pipeline” report. This generic report would be grouped by Salesperson (Owner). Without any filters, this would show the pipeline for the entire company. With a filter, you could detect the User that is currently logged into the system, send them to this generic report, with a filter criteria in the URL to specify that you only should display the Sales Pipeline for this specific user. So, instead of creating 1 Pipeline report for every user or making your users customize this report over and over, you can create 1 report that will work for the entire company and also all users. Very useful way to keep the system clean.

For this example, you can place a link on the Account page layout that will take you to a report of all Contacts at the Company.

1) Create your custom report. For this example, just build a simple Contacts and Accounts report.
2) Go into the customize section of this report. Go to the Criteria section.
3) Create a simple criteria item where “Account Name equals blank.” This will be the criteria that will be filled in through the URL.
3a) Feel free to add other criteria like this or any business specific criteria that you might need (ie. State = Florida).
4) Save the report.

5) Now, you will want to take the URL of your report:
6) Add this to your report URL: ?pv0=
So, now you will have

The “pv0” is the variable for that first criteria that you created. If you created multiple “blank” criteria like the Account Name one above, you would also have pv1, pv2, etc for each criteria created.

7) So, if you wanted to test this out, place an Account Name after pv0=. Like CRM . This will bring in the Contact report with only Contacts working for Shamrock CRM.
8) Now, if this worked, you might want to put this as a link (or button) directly on the Account layout, just create a generic button/link and place this URL in it. Instead of hard coding an Account name, use the Account Name merge field. This will dynamically grab the Account Name and place it in the URL.

This will work in any Parent Child relationship.

Awesome, right?

Tags: , , , , ,
Posted in Business Analysis, Campaigns, Reports | 1 Comment » JavaScript to Override Buttons

Written by ShamrockCRM on July 23, 2009 – 7:20 pm

This little snippet of code is written in JavaScript.  This piece of code is simply an example of what you can do by embedding JavaScript into a custom button.

In this example, we have Opportunities and a related custom object called Shipments.  You sell a Product and you ship it, get it?

This button would be displayed on the “Shipments” related list on an Opportunity.  The button would be titled “New Shipment” and would replace the default button.

This button would check if a shipment for this Opportunity is currently “In Progress” and not “Shipped”.  If so, it will not allow the user to create a new shipment.  They should combine this new shipment into the existing one to save on transportation costs.


var result = sforce.connection.query("Select Id From Shipment__c where Status__c = 'In Progress' and Opportunity__c = '{!Opportunity.Id}' ");
var records = result.getArray("records"); 

//If there are no Shipments In Progress, redirect the User to the New Shipment page
if (records.length == 0){
window.parent.location.href="{! urlFor( $Action.Shipment__c.New, $ObjectType.Job__c,null,true)}&CF00N20000001B5jC_lkid={!Opportunity.Id}&CF00N20000001B5jC={!Opportunity.Name}";
//If there are Shipments In Progress for this Opportunity
alert("There is a current job on the system - please complete this job prior to creating a new job");

Tags: , , , ,
Posted in S-Controls,, Web Development | Comments Off on JavaScript to Override Buttons

Populate Custom Lookup Fields from an S-Control

Written by ShamrockCRM on April 4, 2009 – 12:00 pm

Probably the most common request I receive from clients is to automatically populate a new record with fields.  This is a simple process, usually involving an S-Control and some URL parameters.  It gets a little more complicated, however, when you start wanting to populate lookup fields on the new records.

Warning:  This isn’t documented or supported by Salesforce, and could change at any time.

First, you need the ID of the field in question.  If you’ve already created S-Controls to populate new fields, this probably isn’t new to you.  However, if you haven’t, the easiest way is to navigate to the field in question in Setup. (Create > Objects > Object Name > Field Name, for custom objects).  Then, take the ID from the URL of the custom field, for example:

You’ll want to pass this as a URL parameter when creating your new object, with “CF” preceding the ID and “_lkid” appended.  You’ll also want to provide a value for the textbox, as the ID isn’t enough.  So you’ll want to pass something like this for a Contact:


Basically, it just comes down to knowing to append “_lkid” to the ID of the field you’re passing in with the Salesforce ID, as well as providing a value to display in the textbox on the creation screen.  Hopefully this helps you out!

Tags: , , , , ,
Posted in S-Controls, | 3 Comments »