Salesforce Dashboard Rotation and Refresh with Tampermonkey

Have you ever wanted to rotate through a series of Salesforce dashboards and have them auto refresh? There are multiple questions on the success community and other forums requesting exactly this. The easiest way to rotate through dashboards is to use a browser plugin that switches between pages. However, data in the dashboards can only be scheduled to refresh once per day. A more frequent refresh requires a user to click the refresh button on the dashboard page.

Enter the Tampermonkey browser plugin and a little Javascript. Tampermonkey is a plugin that allows you to execute Javascript code when a page loads in the browser. To solve the problem of getting a refreshed rotation of dashboards, I wrote a little Javascript code that will redirect to a series of dashboard URLs and automatically click the refresh button without user interaction.

Read more

Alert with Option Buttons in the Window Body – jQueryUI in a Salesforce Custom Button

Here is another example of using jQueryUI in a Salesforce custom button. I’m referencing Super Clone Pro pages that use different configurations for cloning in this example. This could easily be adapted for other pages or actions. Enjoy! {!REQUIRESCRIPT(‘//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js’)} {!REQUIRESCRIPT(‘//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js’)} var $j = jQuery.noConflict(); $j(function() { var winHead = ” + ”; var winBody = … Read more

Using the Enter Keypress Event in Visualforce to Search or Change Checkbox Properties

Perform common actions like run a search or check a checkbox when the enter key is pressed, instead of form submission. The example below shows how to do this with help from jQuery in the Visualforce page.

Things to notice:

  • jQuery.noConflict() prevents conflicts with other javascript that Salesforce may have loaded.
  • j$(document).ready will run the contained JavaScript after the components are loaded on the page. Binding event handling to elements could be missed without this.
  • event.keyCode == 13 is the key code for the Enter button.
  • CSS classes are used to attach the keypress event handling, but you could also specify element types, names, or any other valid selector logic.
  • searchFilter CSS class could be used on text, drop down/picklists, checkboxes, etc.
  • .trigger(‘click’) is used below. It is similar to .click(), and they are interchangeable for this example. The difference that I’m aware of is .trigger(‘click’) can accept additional parameters.
  • Probably only one or two of the methods below would be used in a real project. Multiple options are documented to illustrate different options.

Read more

Javascript Popup Window Tips for Salesforce

Check if a Popup Blocker Prevented the Popup Window Most browsers will block popup windows the first time a popup window tries to appear. Here is how to check if a popup window was blocked. var win = window.open(“/apex/PopupWindowVfPage”, “MyWinName”, “height=500,width=500”); // set the focus new window win.focus(); // assign the methods focusPopup to the … Read more