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
Tom HoodTom Hood 

Lightning Experience replacements for OnClick Javascript Custom buttons

Our organization currently uses OnClick Javascript custom buttons for most of our tasks (phonecalls, contact management, events, etc.), and looking to the future and potential of Salesforce Lightning, we would like to begin the migration process, however we need replacements for our buttons. I've been browsing around on the forums here for a few days and it seems like people have has sucess using visualforce pages, flows, and lightning component ui:buttons, so I'm curious as to which one might be the best choice for our organization, and also what the differences between them are. We are looking for one that functions and codes similarly to the classic Javascript buttons. 

As an example, here is the code to one of our buttons. This code is for our "in progress" button, which is clicked whenever a contact is being called during an event, and the click removes the contact from the call list so that the person is not called twice or at the same time.

/* This code allows the javascript to access the API and push data into the Org.*/ 
sforce.connection.session = "{!$Api.Session_ID}"; 

function updateTask( ) 


var task = new sforce.SObject("Task"); 
task.Id = "{!Task.Id}"; 
task.Status = "In Progress"; 
task.OwnerId = "{!User.Id}"; 
var result = sforce.connection.update([task]); 
if (result[0].getBoolean("success") == false ) { 

catch (e) { 


If I was to rewrite this as a visualforce page, flow, or lightning component ui:button, how would I go about that? Any help is greatly appreciated. Thank you.
Darshan Gandhi 9Darshan Gandhi 9

Tom Hood - I think you can start with lighting buttons and use custom code and controller to migrate the existing code. 
Lighting buttons (
You can have several references from aura doc. just use  AURA DOCS (https://your lightning host name /auradocs/
Also, you can look into trailhead courses to begin with Component + Controller ( Now if you want to call backend service , you can write <aura:component controller="Your apex class name" /> and then call method from controller using actions in salesforce


Let me know if you  need more help and 


Please select as best answer if it helped you