4

I have a lightning component loaded in to a visual force page; VF page is called via an action.

Once I try to load this action from a mobile device/simulator I could see a standard save and cancel buttons.

How could I access these save/cancel buttons? How if I want to execute a js/Apex method call on click on the "save" button?

Thanks in advance

Please see the attached screenshots for further info;

Mobile UI

enter image description here

Quick Action

enter image description here

  • 1
    Sort of looks like they have been pushed off the bottom...is that what has happened? If so, you should be able to still see them in the DOM browser I suspect. – pchittum Dec 2 '15 at 10:21
  • @Hasantha I don't think you would be able to run your script on save/cancel which were added by default on update/create quick action. If you want to do that you could go for lightning component in quick action and action with visualforce page where you will have complete control what you want to write on save and cancel. Yes it will involve complete custom coding. – Kiran Machhewar Aug 1 '17 at 23:56
0

I Hope below code would help you in overcoming your issue.

VisualForce Page

<apex:page controller="tes_button">    
<apex:includeScript value="/lightning/lightning.out.js"/>
<div id="lightning">
    <script>
    //creating lightning component
    $Lightning.use("c:ltng_app",function(){
        $Lightning.createComponent("c:test_1",
                                  {label : ""},
                                  "lightning",
                                  function(cmp){
            console.log("component is being created here");
            });
    });
    </script>
</div>
<script src='/canvas/sdk/js/publisher.js'></script>
<script>        
    // When the panel is displayed, enable the submit button
    Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel", onData:function(e) {
    Sfdc.canvas.publisher.publish({name: "publisher.setValidForSubmit", payload: "true"});}});

// When the save button is pressed, call the apex method, and close the panel
     Sfdc.canvas.publisher.subscribe({ name: "publisher.post", onData: function(e) {
            netx360app.tes_button.hello("test",function(result,event){
                if(event.status){
                    alert("somethin"+result);
                    //  To Close the publisher panel
                    Sfdc.canvas.publisher.publish(
                        { name: "publisher.close", payload:{refresh:"true"}});  }});                
        }});
</script></apex:page>  

Apex class

public class tes_button {
@RemoteAction
public static String hello(String val){
    return 'Hello ' + val;
}}
  • Can you edit your answer to include some information on what this code does? – battery.cord Oct 5 '16 at 14:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.