login

Tip of the Week

Tip of the Week – JavaScript makes multi-select picklists work with dynamic Salesforce Reports

Multi-Select Picklists in Salesforce can be more than a little finicky, and I typically recommend against them. They’re difficult to work with using Apex and Workflow Rules, and using them for grouping in Reports can get sloppy, as they will group by combo rather than individual values. They can generally be replaced by some combination of standard Picklists and Checkboxes, simplifying automations and improving reporting. That said, sometimes they are unavoidable and definitely the right solution. Don’t worry, though, some simple JavaScript can solve the problems associated with Multi-Select Picklists and Dynamic Reports and make them immensely more valuable.

One thing to know – Report filters expect comma-separated parameters, while Multi-Select Picklists generate semicolon-separated values. If you want a dynamic Salesforce Report to filter based on any values within a Multi-Select picklist, you’re going to need a complex formula or workflow. Or, you could save some time by swapping your typical dynamic report link with onclick JavaScript and use this handy piece of code to save you time, headaches, and future maintenance! All it does is swap semicolons for commas, meaning your dynamic Salesforce Report can search for records matching any values within your picklist! Give it a try and let us know how it works for you today!

var picklist="{!Opportunity.Multi_Select_Sample__c}";
picklist = picklist.replace(/;/g,',');
window.location.href = "/00Oo00000057RCe?pv0={!Account.BillingState}&pv1="+ picklist;

-Jared and the Salesforce Guys

, , , ,

No comments yet.

Leave a Reply