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
Olga Kim 7Olga Kim 7 

Convert JavaScript Buttons

I started working on a project converting Salesforce org from Classic to Lightning Experience. 
One big part of the project is converting JavaScript Buttons. There are over 130 JS buttons there. I have some understanding of how to convert simple ones but have no idea what to do with those that are more complex like the one below: 
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
var theStatus = "{!Application__c.Application_Status__c}";

if ('{!TODAY() > Application__c.Due_Date__c}'=='true') {
alert("The Application cannot be submitted after the Due Date.");
}
else if ('{!OR(ISBLANK(Application__c.of_Attachment__c),Application__c.of_Attachment__c = 0)}'=='true') {
alert("Please attach the relevant documents in the related attachment section.");
}
else if (confirm("Once Submitted you will not be able to update the application. Do you want to Submit?") == true) {
// identify the record
var a = new sforce.SObject("Application__c");
a.Id = "{!Application__c.Id}";

// make the field change
a.Application_Status__c = 'Submitted';
// save the change
result = sforce.connection.update([a]);
// reload the page
window.location.reload();
} else {
window.location.reload();;
}
}
Please, help me understand:
  • what my first steps should be?
  • where can I find some solutions for converting JS Buttons?
  • Can I use lightning flows to add validation to the buttons?
  • LWC or Aura Component? 
I will appreciate any advice. 
Thank you  
Best Answer chosen by Olga Kim 7
ANUTEJANUTEJ (Salesforce Developers) 
Hi Olga,

>> Need Help Converting Your Classic JavaScript Buttons to Quick Actions? – Sara Has No Limits (saramorgan.net)

>> Convert JavaScript Buttons to Lightning-Friendly Alternatives with the Lightning Experience Configuration Converter | Salesforce Developers Blog

>> Lightning Alternatives to JavaScript Buttons | Salesforce Trailhead

I was able to find these articles that mentions the use cases of converting javascript buttons to lightning equivalents and in the first link, there are implementations that are in github you can try checking in your demo org.

>> Convert JavaScript Buttons and Links into Lightning Experience Alternatives (salesforce.com)

Additionally, I see that there is a help article that mentioned an out of box tool that can be used have you checked this one?

Generally, we use flows when we want to have a screen component to get data from fields and validate upon those fields if your use case looks something like this then you can certainly use the flows.

I was able to find this link that has implementations for various scenarios and examples : 
https://www.accidentalcodersf.com/2020/07/flow-types-salesforce.html

I would also recommend you to check other types of flows that can be used.

 Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.