I am trying to create case table in Community with first column which will show Case Number and will be link to record page.

I created formula field Show_Case__c [formula: "/"&id]. Also I reference it :

 {label: 'Case Number', fieldName: 'Show_Case__c', type: 'url',sortable: true,typeAttributes: {label: { fieldName: 'CaseNumber'}}}


<aura:attribute name="columns" type="List"/>
<aura:attribute name="data" type="Object"/>

<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

<aura:if isTrue="{!not(empty(v.columns))}">
    <lightning:datatable aura:id="myTable" columns="{!v.columns}" data="{!v.data}" keyField="Id"  hideCheckboxColumn="false"  />


public static List<Case> getCases1(){
    List<Case> cases = [SELECT  Show_Case__c, Id, CaseNumber FROM Case];
    return cases;


tableset : function(component,event,helper) {

        var queryaction = component.get("c.getCases1");
         queryaction.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {


                var columns = [{label: 'Show_Case__c', fieldName: 'CaseNumber', type: 'url',sortable: true,filterable: true,typeAttributes: {label: { fieldName: 'CaseNumber'}}}];


The error which I receive is Cannot read property 'type' of undefined.

I used Hyperlink a Record in lightning:datatable for reference.

How to get this work?

I will appreciate any help. Thank you!

  • Can you provide few extra details like code snippet? Is it exact replica of code you mentioned above? When do you receive this error on load or click of link? Does it provide you with stack trace? May 3, 2018 at 10:39
  • I receive the error on load. I can see from console.log the fields are passed with correct values as shown in the reference link. If I change the places It is showing the id, but not the number as well as it is not working on click of the link. (of course)
    – Jane
    May 3, 2018 at 10:47

2 Answers 2


I found the way to show case number in community as link to record detail!

  1. Create Custom formula field.


LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260)) 
+ 's/detail/' + Id]
  1. Put the field in Apex SOQL query

  2. Then this code will be working

{ label: 'Case Number', fieldName: 'Show_Case__c', type: 'url', sortable: true,typeAttributes: {label:{ fieldName: 'CaseNumber'}} }


I hope the issue is somewhere else. I tried the same code and it is working for me. Another thing I noticed, you don't have to explicitly parse the JSON (JSON.parse(JSON.stringify(response.getReturnValue()))).

You can set the response directly cmp.set('v.mydata', response.getReturnValue()); in the datatable.

Component Markup

<aura:component controller="lightningTableController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:appHostable" access="global">
    <aura:attribute name="title" type="string" default="My Cases" />
    <aura:attribute name="mydata" type="Object"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>    
    <lightning:card title="{!v.title}">
        <lightning:datatable data="{!v.mydata}" 

Component Controller

    init: function (cmp, event, helper) {
        var action = cmp.get('c.getCases');
        action.setCallback(this, function (response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                cmp.set('v.mydata', response.getReturnValue());
                cmp.set('v.mycolumns', [
                    {label: 'Case Number', fieldName: 'Show_Case__c', type: 'url',sortable: true,typeAttributes: {label: { fieldName: 'CaseNumber'}}},
                    {label: 'Subject', fieldName: 'Subject', type: 'text'},
                    {label: 'Status', fieldName: 'Status', type: 'text'}
            } else if (state === "ERROR") {
                var errors = response.getError();


public class lightningTableController {
    public static List<Case> getCases() {
        List<Case> cases = [SELECT Id, CaseNumber,  Subject, Status, Show_Case__c FROM Case];
        //Add isAccessible() check
        return cases;

Screen Capture

enter image description here

  • For me is working in lightning but not in community
    – Jane
    May 3, 2018 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .