[SalesForce] How to convert Hyperlink in formula field

As Salesforce is disabling the use of JavaScript in Hyperlink function in formula fields, as per this documentation: Hyperlink Formula Fields for JavaScript Disablement

I am working on changing one formula field.

I have created a custom link with Execute JavaScript functionality. But custom links will be displayed at the bottom of the page.

Is there any alternative way where I can get this link on random place on the page layout?

Any suggestion is greatly appreciated.

Best Answer

Its not possible to place a button anywhere in layout. Can be done by a inline page which simply redirects, but it would be an overkill for such a simple requirement.

Possible solutions are mentioned in documentation: Hyperlink Formula Fields for JavaScript Disablement. Quoting from it:

What action do I need to take?

We recommend that admins begin reviewing their use of JavaScript in hyperlink formula fields and migrate to alternative solutions. This critical update is enabled for all orgs on the auto-activation date of October 30, 2017. Here are some possible workarounds.

  1. Create a Custom Button or Link executing JavaScript
    • Create custom buttons or links executing OnClick JavaScript
    • Supported in Salesforce Classic only
  2. Create a Lightning Experience Quick Action
    • Create JavaScript in a Lightning Experience component that can be executed though a Quick Action button
    • Supported in Lightning Experience only
  3. Create a custom Visualforce Page to redirect to the correct URL
    • If there is a client-side conditional logic to be executed to decide the link to which the user needs to be directed, create an empty Visualforce page and an Apex controller. Pass the required values from the link to controller, execute the logic to decide the URL in controller method and perform the redirect.

We recommend that you test this update in a sandbox or Developer Edition org. Check the behavior of the HYPERLINK function in formula fields.

Based on where you need to execute this action, you have these options.

Related Topic