1

Hi

In the classic version of salesforce ,I created a custom button that runs an apex class using the javascript function sforce.apex.execute.

This custom button was added in the details salesforce pages like Contact or other Object even in a Custom Object, All is working in the classic version.

My problem is that the custom button does not appear in the Lightning Experience version. It's seems that in this new version , also the javascript functionality has been removed.

Is there an another alternative to call an apex class like it ?

Thank you

1
  • You can add custom component to the page.
    – Ashwani
    Apr 9, 2017 at 10:24

1 Answer 1

4

You will have to add custom Lightning Component. Lightning Experience provides ability to add custom built component.

  • Create a custom component having a button which would perform same function as custom button used to perform.
  • Go to Lightning builder, Click new
  • Select Record Page then the Object on which it needs to be shown. enter image description here
  • Choose "Clone Default Saledforce Home page
  • Add the component, and activate that new page.

Another way:

Add Action to the page. - Go to Object - Find Custom, Button and Links Section - Click "New Action" Add the Lightning component you want same as below enter image description here

8
  • thank you for the help , Is it a possible to add this custom action dynamically ?
    – Raphym
    Apr 9, 2017 at 13:50
  • @Raphym once you have the component by custom action. You can change the properties, view of that custom action based on records. It will be re-usable.
    – Ashwani
    Apr 9, 2017 at 13:53
  • I mean dynamically like I was used the meta data service for the classic version of Salesforce.I would like to add it or remove it dynamically , I have a visual force page with a controller and the user will choice on wich object add the trigger and the custom button.
    – Raphym
    Apr 9, 2017 at 13:57
  • 1
    Yes, it would be as actions are part of object layout. Both layouts and lightning components are supported by metadata api @Raphym
    – Ashwani
    Apr 9, 2017 at 14:00
  • I already did it manualy by doing two things : the first is the creation of the aura component (Logic and Style of the action) , and the second is the adding lightning Action wich is linked to this component. I need to add the linked lightning Action dynamically. The aura component will be imported into my org(not dynamically). Can you show me an example about creating a lightning Action on an Object and link it to my aura component ? In brief i want to do this dynamicaly : Click "New Action" Add the Lighting component you want same as below
    – Raphym
    Apr 19, 2017 at 8:10

You must log in to answer this question.

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