[SalesForce] Save button on lightning component missing

I have created new Lightning component and missing Save button at bottom. I can only see Cancel button. What a strange? Am I missing something? What is the solution? see below component.

On standard object, I have added New Action button and selected lightning component.

    <aura:component implements="force:lightningQuickAction,force:appHostable,force:hasRecordId" controller="Test">
 <aura:attribute name="recordId" type="Id" required="true" default="{!v.recordId}" />
</aura:component>

    ({
 doSave : function(component, event, helper) { 
        console.log(component.get('v.recordId'));
        console.log('dosave called');
        var action =  component.get('c.ping');
        action.setParams({ msg : "Hello world" });

        action.setCallback(this, function(response) {
            console.log('setCallback called');
            var state = response.getState();
            if (state === "SUCCESS") {   

                // Display the total in a "toast" status message
                var resultsToast = $A.get("e.force:showToast");
                resultsToast.setParams({
                    "title": "Good day",
                    "message": "Hello World"
                });
                resultsToast.fire();

                // Close the action panel
                var dismissActionPanel = $A.get("e.force:closeQuickAction");
                dismissActionPanel.fire();   

                console.log("From server: " + response.getReturnValue());
            }
            else if (state === "INCOMPLETE") {
                console.log(response.getReturnValue());
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " +
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });

        console.log('calling server-side action');       
        $A.enqueueAction(action);
 }
})

Best Answer

If you are using action with lightning component then you have to add save button in your component the cancel button is the standard one of lightning quick action pop up.

  <aura:component implements="force:lightningQuickAction,force:appHostable,force:hasRecordId" controller="Test">
 <aura:attribute name="recordId" type="Id" required="true" default="{!v.recordId}" />
<button name=“save” value=“save” onclick=“{!c.dosave}”/>
</aura:component>
Related Topic