• Tom O Ward
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I've had some difficulty displaying data from a SOQL query in a lightning data table. Currently I get the column headings but no data.

My intention is to display a series of SOQL queries with 4 columns (row name, SOQL query for this month, SOQL Query for last month, expected value). At this point I only have the SOQL query for one row until I can get the data displaying.

I'm much more experienced with the backend part of this than the front end so I'm sure I'm missing something obvious as to why the data is not displaying

Component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global"  controller="FieldRepQuery">
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    	<aura:handler name="init" value="{! this }" action="{! c.init }"/>
    		<div style="height: 300px">
    		<lightning:datatable data="{! v.mydata }"
        		columns="{! v.mycolumns }"
        		keyField="opportunityName"
        		hideCheckboxColumn="true"/>
             </div>    
</aura:component>
Controller
({
    init: function (cmp, event, helper) {
                
		helper.queryColumns(cmp, event, helper);
        
        helper.queryData(cmp, event, helper);
            
        }          
    
})
Helper
({
	queryColumns : function(cmp, event, helper) {
        
		  cmp.set('v.mycolumns', [
            { label: 'Field', fieldName: 'RowName', type: 'text'},
            { label: 'This Month', fieldName: 'ThisMonth', type: 'text'},
            { label: 'Last Month', fieldName: 'LastMonth', type: 'text'},
            { label: 'Expected', fieldName: 'Expected', type: 'text'}
              ])
	},

 	queryData : function(cmp,event,helper) {
        
        var action=cmp.get('c.getData');
        
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                cmp.set("v.data", response.getReturnValue());
                
            }
        });
        $A.enqueueAction(action);
    }
       
})
Apex query
public class FieldRepQuery {      
@AuraEnabled
    public static List<TableRow> getData(){
        List<TableRow> Data = new List<TableRow>();
        list<AggregateResult> SamplesThs = [SELECT COUNT (Id)cnt FROM Stock_Usage__c WHERE (Product_Transfer_Type__c = 'Sample' AND Transaction_Date__c = THIS_MONTH AND Owner.Id =:UserInfo.getUserId())];
        string SamplesThis = string.valueOf(SamplesThs[0].get('cnt'));
        list<AggregateResult> SamplesLst = [SELECT COUNT (Id)cnt FROM Stock_Usage__c WHERE (Product_Transfer_Type__c = 'Sample' AND Transaction_Date__c = LAST_MONTH AND Owner.Id =:UserInfo.getUserId())];
        string SamplesLast = string.valueOf(SamplesThs[0].get('cnt'));
        TableRow Samples = new TableRow('Samples', SamplesThis, SamplesLast,'5'); 
        system.debug(Samples);
        return Data;
    }
    
    public class TableRow {		
        public string RowName   {get; set;}
        public string ThisMonth   {get; set;}
        public string LastMonth   {get; set;}
        public string Expected       {get; set;}
        
        public TableRow(String RN, string TM, string LM, string E){
            this.RowName = RN;
            this.ThisMonth = TM;
            this.LastMonth = LM;
            this.Expected = E;
        }
    } 
   
}
I've had some difficulty displaying data from a SOQL query in a lightning data table. Currently I get the column headings but no data.

My intention is to display a series of SOQL queries with 4 columns (row name, SOQL query for this month, SOQL Query for last month, expected value). At this point I only have the SOQL query for one row until I can get the data displaying.

I'm much more experienced with the backend part of this than the front end so I'm sure I'm missing something obvious as to why the data is not displaying

Component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global"  controller="FieldRepQuery">
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    	<aura:handler name="init" value="{! this }" action="{! c.init }"/>
    		<div style="height: 300px">
    		<lightning:datatable data="{! v.mydata }"
        		columns="{! v.mycolumns }"
        		keyField="opportunityName"
        		hideCheckboxColumn="true"/>
             </div>    
</aura:component>
Controller
({
    init: function (cmp, event, helper) {
                
		helper.queryColumns(cmp, event, helper);
        
        helper.queryData(cmp, event, helper);
            
        }          
    
})
Helper
({
	queryColumns : function(cmp, event, helper) {
        
		  cmp.set('v.mycolumns', [
            { label: 'Field', fieldName: 'RowName', type: 'text'},
            { label: 'This Month', fieldName: 'ThisMonth', type: 'text'},
            { label: 'Last Month', fieldName: 'LastMonth', type: 'text'},
            { label: 'Expected', fieldName: 'Expected', type: 'text'}
              ])
	},

 	queryData : function(cmp,event,helper) {
        
        var action=cmp.get('c.getData');
        
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                cmp.set("v.data", response.getReturnValue());
                
            }
        });
        $A.enqueueAction(action);
    }
       
})
Apex query
public class FieldRepQuery {      
@AuraEnabled
    public static List<TableRow> getData(){
        List<TableRow> Data = new List<TableRow>();
        list<AggregateResult> SamplesThs = [SELECT COUNT (Id)cnt FROM Stock_Usage__c WHERE (Product_Transfer_Type__c = 'Sample' AND Transaction_Date__c = THIS_MONTH AND Owner.Id =:UserInfo.getUserId())];
        string SamplesThis = string.valueOf(SamplesThs[0].get('cnt'));
        list<AggregateResult> SamplesLst = [SELECT COUNT (Id)cnt FROM Stock_Usage__c WHERE (Product_Transfer_Type__c = 'Sample' AND Transaction_Date__c = LAST_MONTH AND Owner.Id =:UserInfo.getUserId())];
        string SamplesLast = string.valueOf(SamplesThs[0].get('cnt'));
        TableRow Samples = new TableRow('Samples', SamplesThis, SamplesLast,'5'); 
        system.debug(Samples);
        return Data;
    }
    
    public class TableRow {		
        public string RowName   {get; set;}
        public string ThisMonth   {get; set;}
        public string LastMonth   {get; set;}
        public string Expected       {get; set;}
        
        public TableRow(String RN, string TM, string LM, string E){
            this.RowName = RN;
            this.ThisMonth = TM;
            this.LastMonth = LM;
            this.Expected = E;
        }
    } 
   
}
Hi there,

I am trying to utilize the lightning-map Lightning Web Component for the standard Account object. It works beautifully when displaying the data on the map and in the built in list view. My issue though is that it does not open up the record when I click on either the map marker or the item in the list view, instead it just refreshes the page. Has anyone else seen this issue? 

My LWC is using Lightning Out in an Aura App within a Visualforce page. As I mentioned before, everything is properly displaying as expected, but all that is wrong is that the page refreshes upon clicking what look like hyperlinks to the Account records. 

Any help is much appreciated! Thank you!