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
Gianluca MarianiGianluca Mariani 

Javascript at page load for account or lead

Hello,
I'm quite new to developing in SalesForce. I'm a developer for many years but never used SalesForce until now.
What I want to know if it is possible to write my own custom javascript function at page load of Account Lead or Opportunity. Is it possible? I want to change some UI with jQuery and add some JS function. My company use Lighting.
Any help is much appreciated
Vinay MVinay M

Hi Gianluca Mariani,
   Yes you can do that, go to "Buttons,Links, and Actions" under specific object (for instance, Account), and click on Edit for "Accounts tab". You can replace the standard behaviour with Lightning component for Lightning experience or Visual force page for Classic experience. Similary, you can also override behaviour of buttons like "New" with custom pages. Also, refer to Salesforce documenation when considering to over ride standard actions : https://help.salesforce.com/articleView?id=standard_actions_overrides.htm&type=5 . Hope this will help. 

 

Gianluca MarianiGianluca Mariani
Hello Vinay m,
thanks for your answer, I look around and it's very interesting but it's not exactly what I need. I don't want to create a new view or object but inject JQuery or Javascript in the page for change existing element. For example I want to transform the phone number of a account or lead in a hyperlink with a custom url generated by code? Is that Possible? How?
Vinay MVinay M

I am not sure if I understood you requirement properly, but there is "URL Hack" functionality in Classic, and also available in Lightning from Spring'20 release. With this you can transform data in desired fields. Take a look at this release notes from Salesforce 

https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_general_lex_navigate_to_record_dfv.htm