• Giorgio Bonifazi
  • 0 Points
  • Member since 2017
  • Managment Engineer
  • Aesys S.r.l

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 10
    Likes Given
  • 0
  • 1
I just started working on lightning datatable.

The code is working but StageName , closedate and amount values are not displayed.
public class DataTableController {

    public static List<Opportunity> getOpportunities()
        List<Opportunity> oppList=new List<Opportunity>();
        oppList=[select name,Account.Name,StageName,CloseDate,Amount from Opportunity
                       where StageName != NULL
                       Amount != NULL
                       order by Account.Name];
        return oppList;

<aura:component implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes" 
        <!-- Three important parts of datatable is Key , data and columns
         so we need attribute for data and columns(metatadata)-->
    <!-- attributes -->
    <aura:attribute name="data" 
    <aura:attribute name="columns" 

    <!-- handlers-->
    <aura:handler name="init" 
    <!-- the container element determine the height of the datatable -->
    <div style="height: 300px">
        <lightning:datatable aura:id="opportunitydatatable"

	doInit : function(component, event, helper) {

	queryColumns : function(component,event,helper) {
		  component.set('v.columns', [
            {label: 'Opp Name', fieldName: 'Name', type: 'text'},
            {label: 'Acc Name', fieldName: 'Name', type: 'text'},
            {label: 'StageName', fieldName: 'Stage Name', type: 'text'},
            {label: 'CloseDate', fieldName: 'CloseDate', type: 'text'},
            {label: 'Amount', fieldName: 'Amount', type: 'decimal'}  
    queryContacts : function(component,event,helper) {
        var action=component.get('c.getOpportunities');
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.data", response.getReturnValue());
I need to know two things
a. what is the issue I am facing and how to resolve it
b. How many columns in total can we display in datatable

Helo Helpers

I  have a simple  lightning card which has a title and a footer  and in the body  a list  of  string
I  would like  to have different background color for title  section  for Footer section  and if  possible for  the body  section

I guess I  have to play  wiht the STYLEs  and/or  class  but I  am not familiar  with these.
See below  the code of  my  component 

<lightning:card class="slds-text-heading_small slds-card_boundary"   title="attribute1"  footer="attribute2" >
    <div class="slds-p-left--medium slds-p-right--medium">
        <ul class="slds-list--vertical slds-has-dividers--top-space">
            <aura:iteration  items="{!v.items}" var="item" indexVar="i">
                <li class="slds-list__item">                   

Any  sugeston of  code fragment welcommed

thanks in advance 
Is there a way to refresh the data in a lightning datatable after making an update via an apex class?
I am currently using Flow Builder Spring 19'. I have a situation where I need to change the Record Type.
I DONT want to use APEX.
I am hardcoding the RecordTypeId = xxxxx to change the value of record type.
Will the RecordTypeId change between sandbox and prod, or its same, or i need to take some precaution while migrating changes to PROD, or any better suggestions?

Many thanks in advance!
I want to set record type while creating record in lightning component through e.force:createRecord. But I am not able to do so.
I tried using custom label and even I tried hardcoding still It is not showing correct record type and it is showing default record type for record creation.
Please find below code for javascript controller:
    doInit: function (component, event, helper) {
        var recId = component.get("v.recordId");

        var action = component.get("c.getdetails");
            "sId": recId
        action.setCallback(this, function (response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                console.log("Success" + JSON.stringify(response.getReturnValue()));
                component.set("v.sampleRequest", response.getReturnValue());
                var sampProd = component.get("v.sampleRequest");
                 if(sampProd.Lead__c === sampProd.Contact__c){
                    var Name = sampProd.Contact__r.Name;
                   var Name = sampProd.Lead__r.Name; 

                var createSampleProduct = $A.get("e.force:createRecord");
                var staticRecordLabel = $A.get("$Label.c.UsCanSampleProductRecordType");
                    "entityApiName": "Sample_Product__c",
                    "RecordTypeId": '0121b0000004aeSAAQ',
                    "defaultFieldValues": {
                        'Sample_Request__c' : component.get("v.recordId"),
                        'Name__c': Name,                    
            } else {

I tried hardcoding:
              var staticRecordLabel = $A.get("$Label.c.UsCanSampleProductRecordType");
                    "entityApiName": "Sample_Product__c",
                    "RecordTypeId": '0121b0000004aeSAAQ',

I have tried using:

            var staticRecordLabel = $A.get("$Label.c.UsCanSampleProductRecordType");
                    "entityApiName": "Sample_Product__c",
                    "RecordTypeId": staticRecordLabel ,

it is just showing for 1 sec 
UsCanSampleProductRecordType and then it is taking me to record creation page with default record type.

Please help. 

I'm trying display a message error on lightning component when i get some error on my apex class, like when my select returns zero records.Or my field doesent have the rigth formatt.

Please, can anyone could help me?

i have created a lightning datatable and in that i have a column that displays text formula field. But the table shows html instead of image. Any solution for this??


So i am trying to implement the "Infinite Scrolling to Load More Rows" in a datatable.  I am trying to implement the example found at https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_datatable.htm.  However there is a helper method called in the JS Controller called "fetchData" that is not there and i cant for the life of me make it myself.  I have tried everything.  Any help would be greatly appreciated.

Please see code below.

<aura:component controller="ContactController" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="mydata" type="Object" />
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="isLoading" type="Boolean" default="true"/>
    <aura:attribute name="contactId" type="Id" />
    <aura:attribute name="sortedBy" type="String" />
    <aura:attribute name="sortedDirection" type="String" /> 
    <aura:attribute name="enableInfiniteLoading" type="Boolean" default="true"/>
    <aura:attribute name="initialRows" type="Integer" default="10"/>
    <aura:attribute name="rowsToLoad" type="Integer" default="50"/>
    <aura:attribute name="totalNumberOfRows" type="Integer" default="300"/>
    <aura:attribute name="loadMoreStatus" type="String" default=""/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <div style="height: 500px">
        <lightning:datatable data="{! v.mydata}" 
                             columns="{! v.mycolumns }" 
                             onloadmore="{! c.loadMoreData }"/>
    {! v.loadMoreStatus}

JS Controller:

    init: function (cmp, event, helper) {

        var actions = [
            { label: 'Show details', name: 'show_details' },
            { label: 'Delete', name: 'delete' }
        cmp.set('v.mycolumns', [
            // Other column data here
            { type: 'action', typeAttributes: { rowActions: actions } }
        cmp.set('v.mycolumns', [
            {label: 'Contact Name', fieldName: 'Name', type: 'string', sortable: 'true'},
            {label: 'Phone', fieldName: 'Phone', type: 'phone', sortable: 'true'},
            {label: 'Email', fieldName: 'Email', type: 'email', sortable: 'true'}
    getSelectedName: function (cmp, event) {
        var selectedRows = event.getParam('selectedRows');
        // Display that fieldName of the selected rows
        for (var i = 0; i < selectedRows.length; i++){
            alert("You selected: " + selectedRows[i].Name);
    handleRowAction: function (cmp, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        switch (action.name) {
            case 'show_details':
                alert('Showing Details: ' + JSON.stringify(row));
                cmp.set('v.contactId', row.Id);
                var attribute1 = cmp.get('v.contactId');
                var childComponent = cmp.find('child');
            case 'delete':
                var rows = cmp.get('v.mydata');
                var rowIndex = rows.indexOf(row);
                rows.splice(rowIndex, 1);
                cmp.set('v.mydata', rows);
    //Client-side controller called by the onsort event handler
    updateColumnSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        var sortDirection = event.getParam('sortDirection');
        // assign the latest attribute with the sorted column fieldName and sorted direction
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);     
    loadMoreData: function (cmp, event, helper) {
        //Display a spinner to signal that data is being loaded
        event.getSource().set("v.isLoading", true);
        //Display "Loading" when more data is being loaded
        cmp.set('v.loadMoreStatus', 'Loading');
        helper.fetchData(cmp, cmp.get('v.rowsToLoad'))
            .then($A.getCallback(function (data) {
                if (cmp.get('v.mydata').length >= cmp.get('v.totalNumberOfRows')) {
                    cmp.set('v.enableInfiniteLoading', false);
                    cmp.set('v.loadMoreStatus', 'No more data to load');
                } else {
                    var currentData = cmp.get('v.mydata');
                    //Appends new data to the end of the table
                    var newData = currentData.concat(data);
                    cmp.set('v.mydata', newData);
                    cmp.set('v.loadMoreStatus', '');
               event.getSource().set("v.isLoading", false);


This is where i need the help to come up with a helper method that is referenced in the JS controller.  THANK YOU!

can i get all the values of a picklist field in a list some how?

I have picklist type custom field in the product. having some options.
In my apex class i want to use these options. can I get them some how throught code? 
what is the difference between bulk api and batch apex?
is bulk api an substitute for batch apex and can we write code in bulk api based on business requirement?
How many records does BULK api process compared to batch apex
Do we have to manually write entire code when using BULK api to salesorce or is there in auto generate tool?

what errors do we encounter in bulk api?

like batch classescan multiple bulk api's be chained?

Please help me in understanding.



I am accessing custom setting values in my apex code and its working fine. When I am calling it through test class then No values gets in from Custom Setting. It always blank in test class. Can somebody help me to understand why custom settings values are not accessible in test class.



Vinod Kumar