Execute Javascript from Formula field

March 6, 2015

Yes, formula fields can be used to execute javascript code on click. For this, we make use of the HYPERLINK Function.

The syntax for it is:

HYPERLINK("javascript:<your javascript code>","TEXT")


To reload the page:


To open a SubTab:

HYPERLINK("javascript:sforce.console.getEnclosingPrimaryTabId(function(result){sforce.console.openSubtab(result.id, '', true, '' , null);})")  [DEPRECATED FOR USE IN STANDARD SERVICE CONSOLE - USE SRCUP INSTEAD]

Go ahead and knock yourself out!