function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
akkkakkk 

I am getting a issues with Registration form with oura component

Hi all ,

i am getting a issus with the Registraion form when i am inserting the Records this is my Code
this is my calss
public class CustomerRegistrationClass {
        @auraEnabled
    public static string createAccount(Account acc){
        // exception handaling
        try{
            insert acc;
            return acc.Id;
        }catch(exception e){
            return 'Exception:'+e.getMessage();
        }
    }
}
this is my application :-
<aura:application extends="force:slds" controller="CustomerRegistrationClass">
    <aura:attribute name="accountRecord" type="Account" default="{
                                                                 'sobjectType':'Account',
                                                                      Industry:'Education'
                                                                 }"/>  <!--     its by defult industry-->
        <div class="slds-container--x-large slds-m-left_xx-large">
            <lightning:card title="Customer Registration Form" iconName="standard:account">
                <aura:set attribute="actions">
                    <lightning:button label="Save" onClick="{!c.saveData}"/>                
                    <lightning:button label="Cancel" onClick="{!c.cancelData}"/>
                        
                </aura:set>
                <div class="slds-m-left_x-large slds-m-right_x-large">
                    <lightning:input label="Name" value="{!v.accountRecord.Name}"/>
                    <lightning:input label="Phone" value="{!v.accountRecord.Phone}"/>
                    <lightning:input label="Industry" value="{!v.accountRecord.Industry}"/>
                </div>    
             </lightning:card>
    
    </div>
    
    
</aura:application>
this is my component :-
({
    saveData : function(component, event, helper) {
        var account = component.get("v.accountRecord"); //showing the defult valus
        alert('test message');
        console.log(account);
        
        var action = component.get("c.createAccount"); // action with Apex calss method so called c
        action.setParams({"acc":account});
        action.setCallback(this,function(response){
            var state = response.getState();
            console.log(state);
            if(state == "SUCCESS"){
                var result= response.getReturnValue();
                console.log(result);
                alert(result);
            }
        })
        $A.enqueueAction(action);
    },// one function completed on save data
    cancelData: function(component, event, helper){
        component.set("v.accountRecord",null);
    }
})

thanks
akhan
ANUTEJANUTEJ (Salesforce Developers) 
Hi Akhan,

May I know what are the issues you are facing??

Regards,
Anutej
akkkakkk
hey i am not getting the  data into data base .
sachinarorasfsachinarorasf
Hi Aqleem Khan,

Please change the onClick  to   onclick in the following  two lines on the application component.

 <lightning:button label="Save" onClick="{!c.saveData}"/>                
 <lightning:button label="Cancel" onClick="{!c.cancelData}"/>
And After changing 'C' to 'c'  in onClick  I have tested it and it worked for me.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
www.sachinsf.com