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
Sriram Varma 1Sriram Varma 1 

create a lightning component of employee details,custom object

create a lightning component of employee details,custom object
PriyaPriya (Salesforce Developers) 

Hi Sriram,

Do you want to display the record of custom object Employee in lightning compoennt?? 

If yes, then check below example that matches your requirement :- 

https://salesforce.stackexchange.com/questions/184318/lightning-component-to-display-custom-object-records

Please mark as Best Answer so that it can help others in the future.

Regards,

Priya Ranjan

 

ANUTEJANUTEJ (Salesforce Developers) 
Hi Sriram,

Link: https://developer.salesforce.com/forums/?id=9060G000000I5KoQAK

The below code snippet is an implementation of showing records of a custom object you can modify it to fit the employee details custom object:
 
component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Suraj Tripathi 47Suraj Tripathi 47
Hi Sriram,

The below code is showing the records of Employee which is a custom object:
 
Comp:
<aura:comp implements="force:appHostable" controller="FetchEmployees" >
    <aura:attribute name="emp" type="Employee__c[]"/>
    <ui:button label="Get All Employees" press="{!c.myAction}"/>
    <aura:iteration var="em" items="{!v.emp}" >
    <p>{!em.name}</p>
    </aura:iteration>
</aura:comp>

Controller:
({
   myAction : function(comp, eve, hel) {
        var action = comp.get("c.getAllEmployees");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                comp.set("v.emp", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchEmployees {
@auraEnabled
    public static List<Employee__c> getAllEmployees()
    {
     List<Employee__c> emp=new LIST<Employee__c>();  
        emp=[select id,name,Email__c from Employee__c];
        return emp;
    } 
    public Employee__c getSelectedEmployees(Id id)
    {    
      Employee__c  emp=[select id,name,Email__c from Employee__c where id=:id];
        return emp;
    } 
   
}


here is a Reference Link: https://developer.salesforce.com/forums/?id=9060G000000I5KoQAK

If you find your Answer then Mark as the best Answer.

Thanks and Regards,
Suraj Tripathi.