function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ArchieTechie6ArchieTechie6 

Javascript in formula field

Hello All,

I want to know how to write Javascript in formula field. 
Something similar to this blog: https://sfdc-gyaan.rhcloud.com/2014/04/referencing-javascript-file-from-static-resources-in-formula-fields/

I have a formula field. When clicked on it, I want to perform an action using JS.
HYPERLINK("javascript:alert('Hello World! - Formula Field');var html_doc = document.getElementsByTagName('head')[0];var js = document.createElement('script');js.setAttribute('type','text/javascript');js.setAttribute('src','/resource/********/HelloJS');html_doc.appendChild(js);js.onload= function() { sayHelloFromAnotherJS(); }; ","_self")

And then, I get this error:

Error: Incorrect argument value for function 'HYPERLINK()'. Javascript is not allowed.
Can anyone help me here? 
Best Answer chosen by ArchieTechie6
Gaurav Jain 7Gaurav Jain 7
Starting with the Spring ‘17 release*, Salesforce eliminate the use of JavaScript in hyperlink formula fields

https://help.salesforce.com/articleView?id=000249336&type=1

Please check below link for a workaround:

http://www.shelovestocode.com/2017/05/javascript-in-salesforce-formula-custom.html

Mark it as Best Answer, if it helps​

All Answers

Gaurav Jain 7Gaurav Jain 7
Starting with the Spring ‘17 release*, Salesforce eliminate the use of JavaScript in hyperlink formula fields

https://help.salesforce.com/articleView?id=000249336&type=1

Please check below link for a workaround:

http://www.shelovestocode.com/2017/05/javascript-in-salesforce-formula-custom.html

Mark it as Best Answer, if it helps​
This was selected as the best answer
ArchieTechie6ArchieTechie6
Thank You for the response Gaurav Jain 7 ..
This helps as I am really new to salesforce.
Ankit Bhati 1Ankit Bhati 1
Hello @ArchieTechie6 & @Gaurav Jain 7 any one can help me one above issue . As I need to remove javascript code from formula field but I didn't find any workaround. As link you shared above not working for me . as it shows 404 error in the opening link. can you suggest any one.