• Saroj Sahoo
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
 I am getting below error while trying to insert a record into SF object using lightning Aura. Kidly look once and suggest.

"This page has an error. You might just need to refresh it. Action failed: c:HDFCApp6CreateClientRecordComp$controller$CreateClient [$S is not defined] Failing descriptor: {c:HDFCApp6CreateClientRecordComp$controller$CreateClient}"

Please look once below modified code and kindly suggest.

1. App: HDFCInsuranceApp6

<aura:application extends="force:slds">
<c:HDFCApp6CreateClientRecordComp/>
</aura:application>

2. Comp:HDFCApp6CreateClientRecordComp



<aura:component controller="HDFCCreateClientRecord"
                implements="FlexiPage:availableForAllPageTypes"
                access="global">
<aura:attribute name="AttrClient" type="SS_HDFC_Customer_Detail__C"
default="{'sobjectType':'SS_HDFC_Customer_Detail__C',
'First_Name__c':'',
'Last_Name__c':'',
'Email__C':'',
'Monthly_Salary__c':''
}"/>

<div class="slds-page-header">
<div class="slds-media__body">
<h1 class="slds-page-header__title slds-truncate slds-align-middle" > Welcome to HDFC Insurance </h1>
<h2 class="slds-text-body_small slds-line-height_reset"> Please enter client details </h2>
</div></div>

<div class="container-fluid">
<h3> please enter the candidate information : </h3>
   
<div class="form-group">
<label>First Name : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.First_Name__c}" />
</div>
<div class="form-group">
<label>Last Name : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Last_Name__c}" />
</div>
<div class="form-group">
<label>Email Address : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Email__c}" />
</div>
<div class="form-group">
<label>Monthly Salary: </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Monthly_Salary__c}" />
</div>
</div>

<div class="col-md-4 text-center">
<ui:button class="btn btn-default" press="{!c.CreateClient}">Create</ui:button>
</div>
</aura:component>

  3. Client Side Controller:  

({

CreateClient : function(component, event, helper){
console.log('In Create record function');
var varClient=component.get("v.AttrClient");
if($A.util.isEmpty(varClient.First_Name__c) || $A.util.isUndefined(varClient.First_Name__c)){
alert('First Name is required');
return; }
if($A.util.isEmpty(varClient.Last_Name__c) || $A.util.isUndefined(varClient.Last_Name__c))
{alert('Last Name is required');
return;
}

    helper.helperMethod(component,varClient);
}

})

4. Helper:HDFCInsuranceApp6CompHelper

({

helperMethod : function(component,varClient) {

var action = component.get("c.createRecord");
action.setParams({client : varClient});
action.setCallback(this,function(response){
var state=response.getState();
if(state == "SUCCESS"){


var newEmptyClientRec={'sobjectType':'SS_HDFC_Customer_Detail__C',
'First_name__c':'',
'Last_name__c':'',
'Email__C':'',
'Monthly_Salary__c':''};
component.set("v.AttrClient",newEmptyClientRec);
alert('Record is created Successfully');

} else if(state == "ERROR"){
alert('Errpr om ca;;omg server side action');}

});

$S.enqueueAction(action);
}
})

5. Server side controller ( Apex):HDFCCreateClientRecord

public with Sharing class HDFCCreateClientRecord {

    @AuraEnabled
public static void createRecord (SS_HDFC_Customer_Detail__C client){

try{

system.debug('HDFC record'+ client);
if(client !=null){
insert client;

}
} catch(Exception ex){
System.debug('Inside Apex class') ;  
}
}

I am getting beow error  (after providing input from UI and when I am clicking the ui press button) while trying to insert a record into SF object using Ligtning Aura. Kindly look once my code and suggest.


"This page has an error. You might just need to refresh it. Action failed: c:HDFCApp6CreateClientRecordComp$controller$CreateClient [component is not defined] Failing descriptor: {c:HDFCApp6CreateClientRecordComp$controller$CreateClient}" 


1. App: HDFCInsuranceApp6

<aura:application extends="force:slds">
<c:HDFCApp6CreateClientRecordComp/>
</aura:application>

2. Comp:HDFCApp6CreateClientRecordComp



<aura:component controller="HDFCCreateClientRecord"
                implements="FlexiPage:availableForAllPageTypes"
                access="global">
<aura:attribute name="AttrClient" type="SS_HDFC_Customer_Detail__C"
default="{'sobjectType':'SS_HDFC_Customer_Detail__C',
'First_Name__c':'',
'Last_Name__c':'',
'Email__C':'',
'Monthly_Salary__c':''
}"/>

<div class="slds-page-header">
<div class="slds-media__body">
<h1 class="slds-page-header__title slds-truncate slds-align-middle" > Welcome to HDFC Insurance </h1>
<h2 class="slds-text-body_small slds-line-height_reset"> Please enter client details </h2>
</div></div>

<div class="container-fluid">
<h3> please enter the candidate information : </h3>
   
<div class="form-group">
<label>First Name : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.First_Name__c}" />
</div>
<div class="form-group">
<label>Last Name : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Last_Name__c}" />
</div>
<div class="form-group">
<label>Email Address : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Email__c}" />
</div>
<div class="form-group">
<label>Monthly Salary: </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Monthly_Salary__c}" />
</div>
</div>

<div class="col-md-4 text-center">
<ui:button class="btn btn-default" press="{!c.CreateClient}">Create</ui:button>
</div>
</aura:component>

  3. Client Side Controller:  

({

CreateClient : function(component, event, helper){
console.log('In Create record function');
var varClient=component.get("v.AttrClient");
if($A.util.isEmpty(varClient.First_Name__c) || $A.util.isUndefined(varClient.First_Name__c)){
alert('First Name is required');
return; }
if($A.util.isEmpty(varClient.Last_Name__c) || $A.util.isUndefined(varClient.Last_Name__c))
{alert('Last Name is required');
return;
}

    helper.helperMethod(varClient);
}

})

4. Helper:HDFCInsuranceApp6CompHelper

({

helperMethod : function() {

var action = component.get("c.createRecord");
action.setParams({client : varClient});
action.setCallback(this,function(response){
var state=response.getState();
if(state == "SUCCESS"){


var newEmptyClientRec={'sobjectType':'SS_HDFC_Customer_Detail__C',
'First_name__c':'',
'Last_name__c':'',
'Email__C':'',
'Monthly_Salary__c':''};
component.set("v.AttrClient",newEmptyClientRec);
alert('Record is created Successfully');

} else if(state == "ERROR"){
alert('Errpr om ca;;omg server side action');}

});

$S.enqueueAction(action);
}
})

5. Server side controller ( Apex):HDFCCreateClientRecord

public with Sharing class HDFCCreateClientRecord {

    @AuraEnabled
public static void createRecord (SS_HDFC_Customer_Detail__C client){

try{

system.debug('HDFC record'+ client);
if(client !=null){
insert client;

}
} catch(Exception ex){
System.debug('Inside Apex class') ;  
}
}



 
I am getting beow error  (after providing input from UI and when I am clicking the ui press button) while trying to insert a record into SF object using Ligtning Aura. Kindly look once my code and suggest.


"This page has an error. You might just need to refresh it. Action failed: c:HDFCApp6CreateClientRecordComp$controller$CreateClient [component is not defined] Failing descriptor: {c:HDFCApp6CreateClientRecordComp$controller$CreateClient}" 


1. App: HDFCInsuranceApp6

<aura:application extends="force:slds">
<c:HDFCApp6CreateClientRecordComp/>
</aura:application>

2. Comp:HDFCApp6CreateClientRecordComp



<aura:component controller="HDFCCreateClientRecord"
                implements="FlexiPage:availableForAllPageTypes"
                access="global">
<aura:attribute name="AttrClient" type="SS_HDFC_Customer_Detail__C"
default="{'sobjectType':'SS_HDFC_Customer_Detail__C',
'First_Name__c':'',
'Last_Name__c':'',
'Email__C':'',
'Monthly_Salary__c':''
}"/>

<div class="slds-page-header">
<div class="slds-media__body">
<h1 class="slds-page-header__title slds-truncate slds-align-middle" > Welcome to HDFC Insurance </h1>
<h2 class="slds-text-body_small slds-line-height_reset"> Please enter client details </h2>
</div></div>

<div class="container-fluid">
<h3> please enter the candidate information : </h3>
   
<div class="form-group">
<label>First Name : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.First_Name__c}" />
</div>
<div class="form-group">
<label>Last Name : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Last_Name__c}" />
</div>
<div class="form-group">
<label>Email Address : </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Email__c}" />
</div>
<div class="form-group">
<label>Monthly Salary: </label>
<ui:inputText class="form-control" value="{!v.AttrClient.Monthly_Salary__c}" />
</div>
</div>

<div class="col-md-4 text-center">
<ui:button class="btn btn-default" press="{!c.CreateClient}">Create</ui:button>
</div>
</aura:component>

  3. Client Side Controller:  

({

CreateClient : function(component, event, helper){
console.log('In Create record function');
var varClient=component.get("v.AttrClient");
if($A.util.isEmpty(varClient.First_Name__c) || $A.util.isUndefined(varClient.First_Name__c)){
alert('First Name is required');
return; }
if($A.util.isEmpty(varClient.Last_Name__c) || $A.util.isUndefined(varClient.Last_Name__c))
{alert('Last Name is required');
return;
}

    helper.helperMethod(varClient);
}

})

4. Helper:HDFCInsuranceApp6CompHelper

({

helperMethod : function() {

var action = component.get("c.createRecord");
action.setParams({client : varClient});
action.setCallback(this,function(response){
var state=response.getState();
if(state == "SUCCESS"){


var newEmptyClientRec={'sobjectType':'SS_HDFC_Customer_Detail__C',
'First_name__c':'',
'Last_name__c':'',
'Email__C':'',
'Monthly_Salary__c':''};
component.set("v.AttrClient",newEmptyClientRec);
alert('Record is created Successfully');

} else if(state == "ERROR"){
alert('Errpr om ca;;omg server side action');}

});

$S.enqueueAction(action);
}
})

5. Server side controller ( Apex):HDFCCreateClientRecord

public with Sharing class HDFCCreateClientRecord {

    @AuraEnabled
public static void createRecord (SS_HDFC_Customer_Detail__C client){

try{

system.debug('HDFC record'+ client);
if(client !=null){
insert client;

}
} catch(Exception ex){
System.debug('Inside Apex class') ;  
}
}



 
Hi ,

I tried to create my first lightning application but i get the folowing error.

User-added image

Below is my code

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

Component
<aura:component controller='TeacherCreateRecord' >

    <aura:attribute name="client" type="Teacher__c" default="{'sObjectType':'Teacher__c','Name' : '' }" />
    <ui:inputtext label="Enter Teacher Name"   value="{!v.client.Name}" />
    <ui:button label="Submit" press="{!c.createClient}"/>
</aura:component>

Client side contoller
({
    createClient : function(component, event) {
        
        
       //for logs
        console.log("In Client Controller");

        //getting the record info from component to js
        var varClient=component.get("v.client");
       
        //validation to  check of field is empty or not
        if($A.util.isEmpty(varClient.Name) || $A.util.isUndefined(varClient.Name) )
        {
           alert('First name is required');
            //return the value and function will stop
            return;
        }
         
         helper.createRecord(varClient);
    }
})

Helper
({
    createRecord : function() {
         
       
       console.log("In helper");
        
        //calling apex function
        alert('Before action');
        var action = component.get("c.createTeacherRecord");
         
        alert('Before set params function');
        //set the parameters
        action.setParams({
            client : varClient
        });
        
        alert('Before callback function');
        //set callback function
        action.setCallback(this,function(a){
            
            var response=a.getState();
            if(response == "SUCCESS")
            {
                //Reset form and this is optional
                var newrecord= {'sObjectType' : 'Teacher__c','Name':''};
                component.set("v.client",newrecord);
                alert('Record is Created');
            }else if(response == "ERROR")
            {
                alert('Record is not Created');
            }
        });
        //To enqueue all actions and let all happen one by one 
        $A.enqueueAction(action);
    }
    
})

ApexClass
public with sharing class TeacherCreateRecord {
    
    
    @AuraEnabled
    public static void createTeacherRecord(Teacher__c  client)
    {
        try{
            System.debug('Teacher Create Record class'+ client) ;
            if(client != null)
            {
                insert client;
            }
        }
    
       catch(Exception e) 
       {
            System.debug('Inside Apex class') ;   
       }
    }
 }

The object i have used is Teacher__c and i am trying to fetch the name which is a standard field .