• Tom Hood
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
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.*/ 
{!requireScript("/soap/ajax/10.0/connection.js")}; 
sforce.connection.session = "{!$Api.Session_ID}"; 

function updateTask( ) 

try 

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 ) { 
alert(result[0].errors.message); 
return; 

window.top.location.href=window.top.location.href; 

catch (e) { 
alert(e); 
}


updateTask();

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.