• SFDCLLL
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Contoller :

public class AccountComponent
{
    @AuraEnabled
    
    public static string accsearch(string name,string phone)
    {
        system.debug(name);
        system.debug(phone);
        list<account>accList = new list<account>();
        account a = new account();
        a.name = name;
        a.phone = phone;
        accList.add(a);
        try
        {
            insert accList;
            return 'Successfully inserted';
        }
        catch(exception e)
        {
            system.debug(e);            
            return e.getMessage();
        }        
    }
}

Lightning Component :

<aura:component controller="AccountComponent" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="Accountstatus" type="string"/>
    <aura:attribute name="AccountName" type="string"/>
    <aura:attribute name="Phone" type="string"/> 
    <lightning:input type="string" label="Enter Name" value="{!v.AccountName}"/>
    <lightning:input type="string" label="Enter Phone" value="{!v.Phone}"/>
    <lightning:button label="Save" onclick="{!c.accsearch}"/>
    
    {!v.Accountstatus}
    <br/>        
</aura:component>

Controller.js :
({
    accsearch : function(component, event, helper)
    {
        var action = component.get('c.accsearch');
        var name = component.get('v.AccountNam');
        action.setParams({name : name});
        var phone = component.get('v.Phone');
        action.setParams({phone : phone});      
        action.setCallback(this,function(response)
                           {
                               var getrecordstatus = response.getReturnValue();
                               component.set('v.Accountstatus',getrecordstatus);
                               console.log(':',getrecordstatus);
                           },'SUCCESS');
        $A.enqueueAction(action);
    }
})