I've run the Lightning Transition Assistant and identified all the javascript buttons that need to be converted. I'm in the process of starting to manually convert the buttons to be supported in LEX. Now, I haven't done a lot of work with Lightning components. I've gone thru some trailheads and understands the basics. My question is if there may be a easy way to convert the javascript button to a Lightning component or if have to build it more or less from scratch. Here is one of the buttons I'm looking to convert:


// Utility function to create Blob from base64 encoded string 
function b64toBlob(b64Data, contentType, sliceSize) { 
contentType = contentType || ''; 
sliceSize = sliceSize || 512; 
var byteCharacters = atob(b64Data); 
var byteArrays = []; 

for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) { 
var slice = byteCharacters.slice(offset, offset + sliceSize); 
var byteNumbers = new Array(slice.length); 
for (var i = 0; i < slice.length; i++) { 
byteNumbers[i] = slice.charCodeAt(i); 
var byteArray = new Uint8Array(byteNumbers); 
var blob = new Blob(byteArrays, {type: contentType}); 
return blob; 

var box = new SimpleDialog(Dialogs.getNextId(), false); 
box.title = "Fetching Value Program Summary Report"; 
box.isMovable = false; 
box.extraClass = ""; 
box.width = 400; 
box.isModal = true; 
window.parent.box = box; 
box.setContentInnerHTML('<p>Please wait....</p>'); 

var acct = new sforce.SObject("Account"); 
acct.Id = "{!Account.Id}" + "Premier"; 
acct.Premier_Status__c = "{!Account.Premier_Status__c}"; 
var response = sforce.apex.execute("RestifyClient_v2","getReport",{AccountID:acct.Id}); 
var length = String(response).length; 
var statusCode = String(response).substring(16,19); 
var b64Data = String(response).substring(19,length); 
var n = response.indexOf("Error:"); 

if(n == -1 && statusCode == 200 && acct.Premier_Status__c == true) { 

if (navigator.appVersion.toString().indexOf('.NET') > 0) { 
var blob = b64toBlob(b64Data, "application/pdf"); 
var fileURL = URL.createObjectURL(blob); 
window.navigator.msSaveOrOpenBlob(blob, "practiceReport.pdf"); 
} else { 
var blob = b64toBlob(b64Data, "application/pdf"); 
var fileURL = URL.createObjectURL(blob); 
var pdfWin = window.open(fileURL,"_blank","width=1000,height=800"); 
if(!pdfWin && acct.Premier_Status__c == true) { 
box.setTitle("Success: Value Program Summary Report has been retrieved"); 
box.setContentInnerHTML("<p align='left'></p><p align='left'>A popup blocker was detected. The Value Program Summary report will not open automatically.<br /><br /></p><p align='left'><a onclick='window.parent.box.cancel();' target='_blank' href='"+fileURL +"' >Click here to view Value Program Summary report (.pdf)</a><br /><br /></p><p align='center'><button class='btn' onclick='window.parent.box.cancel(); return false;'>Cancel</button></p>"); 
} else { 

else { 
box.setTitle("Error fetching Value Program Summary Report"); 
box.setContentInnerHTML("<p align='left'><img src='/img/msg_icons/warning32.png' style='margin:0 5px;'/></p><p align='left'>The Value Program Summary is an exclusive benefit for Premier Program practices meeting all program targets at the time of the previous program check-in period. If you’re seeing this message, then this account isn’t eligible to receive this quarterly statement.. <br /><br /><br /></p><p align='center'><button class='btn' onclick='window.parent.box.cancel(); return false;'>OK</button></p>"); 

The code looks to be surfacing a PDF and displaying an error message if it doesn't get all the information necessary to compile.

  • There is no easy way :( You have very custom logic in your JS button, you have to migrate it in lightning experince. – Pranay Jaiswal Mar 10 at 17:46
  • @PranayJaiswal that's what I thought, but was hoping there was an easier approach. Thanks for your reply! – Dman100 Mar 10 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.