Recently, I was asked to create a custom button that would allow a user to choose between two SuperClone Configuration options. jQueryUI provides a nice modal dialog that solved the problem. The dialog showed two buttons for the configurations and a cancel button. Below is the sample code for what I put together. The actions…
Read moreCategory: Salesforce
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…
Read moreJavascript 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 moreRemove Last Comma or Other Characters from the End of a String
Apex Removing the last comma is often needed when dynamically building a SOQL Select string. Salesforce quietly released a bunch of new string methods in Winter ’13 that I have started to really appreciate. One of the new methods is removeEnd() and removeEndIngoreCase(). These are great for removing that last comma. String soql = ‘Select…
Read moreHTML Line Breaks in Visualforce using Escape=false with Encoding
Using a Visualforce tag with the escape=off option may help send an html tag like a line break to the page. However, escape=off can open cross-site scripting vulnerabilities. Visualforce encoding functions HTMLENCODE, JSENCODE, JSINHTMLENCODE, and URLENCODE help avoid the vulnerabilities, but they also prevent \n new line characters and html tags from showing on the…
Read more