You need to sign in to do that
Don't have an account?

I created a lightning component but I am unable to fetching the record
I created a Lightning component in which i want to fetch my detail through my apex controller but I am not able to fetch my records on the current record Id.
Apex Controller:
Lightning Controller:
Lightning Helper:
Apex Controller:
public with sharing class ASDcompanyapex { @AuraEnabled public static List<Service_Line__c> getServiceLine(string recordId) { List<Service_Line__c> ServiceLineList =[Select Name, Status__c, Line_Type__c, Total_Effort_Taken__c,Total_Line_Cost__c from Service_Line__c where Status__c = 'Completed' AND Service_Request__c =: recordId]; { return ServiceLineList; } } }Lightning Component:
<aura:component controller="ASDcompanyapex" implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes" access="global"> <aura:attribute name="recordId" type="Id" /> <aura:attribute type="Service_Line__c" name="ServiceLineList"/> <aura:attribute name="mycolumns" type="List"/> <aura:handler name="init" value="{!this}" action="{!c.servicelist}"/> <lightning:datatable data="{! v.ServiceLineList }" columns="{! v.mycolumns }" keyField="{!v.recordId}" hideCheckboxColumn="true"/> </aura:component>
Lightning Controller:
({ servicelist : function(component, event, helper) { var rid = component.get("v.recordId"); helper.fetchServiceLineHelper(component, event, helper); } })
Lightning Helper:
({ fetchServiceLineHelper : function(component, event, helper) { component.set('v.mycolumns', [ {label: 'Service Line Name', fieldName: 'Name'}, {label: 'Status', fieldName: 'Status__c'}, {label: 'Line Type', fieldName: 'Line_Type__c'}, {label: 'Total Effort', fieldName: 'Total_Effort_Taken__c'}, {label: 'Total Line Cost', fieldName: 'Total_Line_Cost__c'}, ]); debugger; var action = component.get("c.getServiceLine"); action.setParams({ }); action.setCallback(this, function(response){ debugger; var state = response.getState(); if (state === "SUCCESS") { component.set("v.ServiceLineList", response.getReturnValue()); } }); $A.enqueueAction(action); } })
Help urgently needed.
Thanks in Advance!
Regards,
Tushar Sharma
https://newstechnologystuff.com/
I found the below link for the developer documentation can you please have a look at it:
>> https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/apex_records.htm
I hope this was helpful in your implementation and in case if this comes handy can you please choose this as the best answer so that it can be used by others in the future.
Hi Tushar
I have the data matching to what I want to display in my component.
I appended the error condition it's not getting saved.
Below is my appended code:
My output of the component is as follow:
There are no records generated.