You need to sign in to do that
Don't have an account?

Lightning Experience and OnClick Javascript Custom Buttons
Curious what the best approach is to replace custom buttons that are currently using OnClick Javascript or URL since they are no longer supported when switching to Lightning Experience. Is it best to replace the classic buttons by building a new buton using the Lightning Design System framework within Lightning components and then adding to the page layout?
Previously a typical Javascript button would contain some code that created an sObject, set the Id to the current record Id, updated some other fields and performed some sforce.connection update of the record.
Now I would say (to be strictly Lightning conformant) that you need to create a Lightning Component consisting of a ui:button using Ligthning Design System, add a client side Javascript controller with a method pointed to by the "press" attribute on the ui:button. That controller calls a client side helper method routing the asynchronous call to an AuraEnabled Apex controller for server side code managinng the update of the record :)
If you want to stick with the sforce.connection or sforce.apex Javascript libraries you could short cuircuit the server side AuraEnabled Apex class, one test class less to write ;)
1.) Create a visual force page. The only purpose of this page is to launch an APEX class controller that opens a URL.
2.) This is an example controller
3.) Create a new action on the opportunity. Associate the visualforce page to the action.
4.) Drag the Action into the appropriate area on the Opportunity page layout.
You can go thru below link , it helped me. Hopefully it does for you as well..
https://developer.salesforce.com/blogs/developer-relations/2016/09/take-the-first-steps-ways-you-can-replace-javascript-buttons.html
Regards,
KK
The logic which you have mentioned works like a charm, however i am struck up with a scenario where i have to open the URL (pagereference) in a different tab. I am not able to use "target" attribute(custom button or link) and "windows.open" (javascript).
Please let me know if you have any idea to do the same.
Thanks
Venkatesh