4

We depend on a javascript button to allow our salesforce screens to interact with another web application. We read some elements from the salesforce contact, and then call a js func hosted on another web site to pass that contact info to the other web site. The js func has a call back, so when the other web site is finished, our js in salesforce can save some data to the salesforce contact.

But.... as lightning lacks javascript buttons, we have been locked out of lightning.

I just found this: https://developer.salesforce.com/blogs/developer-relations/2016/09/why-its-time-to-break-up-with-javascript-buttons-and-embrace-lightning.html

But it is not clear: Can I do a javascript button now in lightning, or do I still need to wait for more pieces from salesforce?

We would love to have a path forward with lightning.

2 Answers 2

3

You can build a quick actions for lightning components .The quick actions can be a way to replace your JavaScript buttons for lightning experience .

Quick actions are lightning components that can use aura enabled apex to make external callouts via apex.

4
  • is there any way to update a field on record details page, and show it updated?. Earlier we use to have ajax toolkit.
    – Ysr Shk
    Commented Apr 21, 2017 at 17:38
  • 1
    I think quick action should take care of that use case .No? Commented Apr 21, 2017 at 17:40
  • No. Actually I am updating a field. Say I am updating a status on button click. Having components creates a popup and even it has problems with update. We are unable to show toast on update as we are refreshing the page to display updated status.
    – Ysr Shk
    Commented Apr 21, 2017 at 17:42
  • You can create a new question with appropriate code and screenshots explaining the problem and that should help me more to understand your scenario . Commented Apr 21, 2017 at 17:44
0

At the moment Lightning can't do external callouts. It can call an Apex method that does the callout, but it has to be a synchronous callout because there's no view state. And there's a limit of only a certain number (20?) of simultaneous synchronous callouts from Apex to the same host.

One dev at my last company had a clever workaround. He put in a hidden iFrame containing a VisualForce page, and designed it such that it could pass messages back and forth with the Lightning component that was hosting it. So Lightning told VisualForce to make the asynchronous callout and got the message back.

Some thoughts from here: http://opfocus.com/button-button-whos-got-the-button/

What can you do about this? Again, your best option is to replace your JavaScript button with a Visualforce button, and develop a Visualforce page that performs the desired action. For example, imagine that, in Salesforce Classic, your Case page has a custom JavaScript button that calls Apex code to close the Case, send an email to the customer, and then refresh the Case page. You can replace that with a Visualforce page that does the same thing. Your users may notice a delay, since, when they click the button, the UI will redirect to your Visualforce page before performing the actions, then redirect back to the refreshed Case page when done. The good news, though, is that you can probably re-use most, if not all, of your original Apex code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .