• ramayya dasam
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies
Hi all ,
     I had also faced the similar issue  (Unable to find action 'createAccount' on the controller of c:Event11comp ).    please go through the code below 
Event :
         <aura:event type="APPLICATION" description="Event template" >
         <aura:attribute name="acc" type="Account"/>
        </aura:event>

component 1 :
  <aura:component >
    <aura:registerEvent name="first" type="c:Event11"/>
    <aura:attribute name="acc" type="Account" default="{'sobjectType':'Account'}" />
    <div style="margin-left:100px;margin-top:100px;width:500px;border:1px solid green;">
        <lightning:card title="" iconName="standard:account">
            <aura:set attribute="title">
                <h1>New customer</h1>
            
            </aura:set>
            <aura:set attribute="actions">
                <lightning:button label="save" onclick="{!c.doSave}"/>
                <lightning:button label="cancel" onclick="{!c.doCcancel}"/>
             </aura:set>
                 <div style="padding:20px;">
                     <lightning:input label="Name"     value="{!v.acc.Name}"/>
                     <lightning:input label="Phone"    value="{!v.acc.Phone}"/>
                     <lightning:input label="Industry" value="{!v.acc.Industry}"/>                  
                </div>
    
    
    
    
        </lightning:card>
    </div>
    
</aura:component>

component 1 controller :
              ({
    doSave : function(component, event, helper) {
        var accRecord = component.get("v.acc");
        var action = component.get("c.createAccount");
        action.setParams({"objA":accRecord});
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state == 'SUCCESS'){
                var res = response.getReturnValue();
                if(res !='Error'){
                var evt = $A.get("e.c:Event11");
                evt.setParams({"acc":accRecord});   
                evt.fire();
            }
            }
        });
        
        
        
        
        
        
        
        $A.enqueueAction(action);
        
    },
    doCancel : function(component, event, helper) {
        component.set("v.acc",null);
    }
})


component 2 :
       <aura:component controller="controllerDml">
    <aura:attribute name="accountdata" type="Account" default="{'sobjectType':'Account'}"/>
    <aura:attribute name="flag" type="boolean"  default="flase"/>
    <aura:handler name="Submit" event="c:Event11" action="{!c.doSubmit}"/>
   
    <aura:if isTrue="{!v.flag}">
     <div style="margin-left:100px;margin-top:100px;width:500px;border:1px solid green;">
       <lightning:card title="customer Details" iconName="standard:account">
           <div style="padding:20px;"> 
            <b>Name</b>     :  {!v.accountdata.Name}<br/>
            <b>Phone</b>    :  {!v.accountdata.Phone}<br/>
            <b>Industry</b> :  {!v.accountdata.Industry}
           </div>
       </lightning:card>
     </div>
    
    
    </aura:if>
    
</aura:component>
component 2 controller:

({
    doSubmit : function(component, event, helper) {
        var acc1 = event.getParam("acc");
        component.set("v.accountdata",acc1);
        component.set("v.flag",true);
        
    }
})

Application:
 <aura:application extends="force:slds" >
    <c:Event11comp />
    <c:Event11comp1 />
    
</aura:application>

Apex class:

 public class controllerDml {
    @auraEnabled
    public static string createAccount(Account objA) {
         try{
             Insert objA;
             return objA.Id;
            }
          catch(Exception e) {
              return 'Error';
               }
    }

}
 
Hi all ,
     I had also faced the similar issue  (Unable to find action 'createAccount' on the controller of c:Event11comp ).    please go through the code below 
Event :
         <aura:event type="APPLICATION" description="Event template" >
         <aura:attribute name="acc" type="Account"/>
        </aura:event>

component 1 :
  <aura:component >
    <aura:registerEvent name="first" type="c:Event11"/>
    <aura:attribute name="acc" type="Account" default="{'sobjectType':'Account'}" />
    <div style="margin-left:100px;margin-top:100px;width:500px;border:1px solid green;">
        <lightning:card title="" iconName="standard:account">
            <aura:set attribute="title">
                <h1>New customer</h1>
            
            </aura:set>
            <aura:set attribute="actions">
                <lightning:button label="save" onclick="{!c.doSave}"/>
                <lightning:button label="cancel" onclick="{!c.doCcancel}"/>
             </aura:set>
                 <div style="padding:20px;">
                     <lightning:input label="Name"     value="{!v.acc.Name}"/>
                     <lightning:input label="Phone"    value="{!v.acc.Phone}"/>
                     <lightning:input label="Industry" value="{!v.acc.Industry}"/>                  
                </div>
    
    
    
    
        </lightning:card>
    </div>
    
</aura:component>

component 1 controller :
              ({
    doSave : function(component, event, helper) {
        var accRecord = component.get("v.acc");
        var action = component.get("c.createAccount");
        action.setParams({"objA":accRecord});
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state == 'SUCCESS'){
                var res = response.getReturnValue();
                if(res !='Error'){
                var evt = $A.get("e.c:Event11");
                evt.setParams({"acc":accRecord});   
                evt.fire();
            }
            }
        });
        
        
        
        
        
        
        
        $A.enqueueAction(action);
        
    },
    doCancel : function(component, event, helper) {
        component.set("v.acc",null);
    }
})


component 2 :
       <aura:component controller="controllerDml">
    <aura:attribute name="accountdata" type="Account" default="{'sobjectType':'Account'}"/>
    <aura:attribute name="flag" type="boolean"  default="flase"/>
    <aura:handler name="Submit" event="c:Event11" action="{!c.doSubmit}"/>
   
    <aura:if isTrue="{!v.flag}">
     <div style="margin-left:100px;margin-top:100px;width:500px;border:1px solid green;">
       <lightning:card title="customer Details" iconName="standard:account">
           <div style="padding:20px;"> 
            <b>Name</b>     :  {!v.accountdata.Name}<br/>
            <b>Phone</b>    :  {!v.accountdata.Phone}<br/>
            <b>Industry</b> :  {!v.accountdata.Industry}
           </div>
       </lightning:card>
     </div>
    
    
    </aura:if>
    
</aura:component>
component 2 controller:

({
    doSubmit : function(component, event, helper) {
        var acc1 = event.getParam("acc");
        component.set("v.accountdata",acc1);
        component.set("v.flag",true);
        
    }
})

Application:
 <aura:application extends="force:slds" >
    <c:Event11comp />
    <c:Event11comp1 />
    
</aura:application>

Apex class:

 public class controllerDml {
    @auraEnabled
    public static string createAccount(Account objA) {
         try{
             Insert objA;
             return objA.Id;
            }
          catch(Exception e) {
              return 'Error';
               }
    }

}