I am using below to convert Subject column to hyperlink as below

{label: 'Subject', fieldName: 'linkName', type: 'url', 
             typeAttributes: {label: { fieldName: 'Subject' }, 
                              target: '_blank'} }, 

and in call back I am setting the Id of the object so that upon cliking the same it will move to the record page.

action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS") {
                var result = response.getReturnValue();
                    if (record.Who) record.ContactName = record.Who.Name;
                    result.linkName = '/'+record.Id;

but instead of making hyperlink it won't show any value, in console log I can see linkName got the id but at the UI level instead of showing any value, it shows nothing. can someone please help! Thank you

  • Hi - it's best to try some sort of implementation first instead of just asking the community to do it for you. Also, best practice is to use the new lightning:navigation rather than the older navigateToSObject component event Apr 24, 2019 at 8:02
  • @BrianMiller Thank you for responding, I have updated my question, could you please take a look again?
    – gs650x
    Apr 24, 2019 at 12:07

1 Answer 1


you have to ways to do this: 1. in the columns of the datatable, add the name of the record you want as URL and label "what ever you want", and when clicking it will navigate to the url with the record.

the column will be something like this:

{label:'FIELD_LABEL', fieldName: 'URL_OF_THE_RECORD', type: 'url', typeAttributes: {label: { fieldName: 'FIELD_LABEL' }}}
  1. add a button with an action, which will call a JavaScript method, that will call the navigateToSObject method.

the column for this way will be something like this:

{label: 'Status', type: 'button', initialWidth: 150, typeAttributes:
                label: { fieldName: 'actionlabel'}
                , title: 'Click to book the event'
                , name: 'book_event'
                , iconName: 'action:join_group'
                , disabled: {fieldName: 'actionDisabled'}
                , class: 'btn_next'}

VERY IMPORTANT: Name "book_event" must be unique if you have more than one button, the name will be used to handle the action "click" of the button

the datatable in the component will look like this:

            columns="{! v.fields }"
            data="{! v.events }"
            errors="{! v.errors }"
            onrowaction="{! c.handleRowAction }"

The method in the "onrowaction" will be fired, when clicking the button.

  • Thank you so much for providing the solution, I am using the first approach and have updated my question, could you please take a look again?
    – gs650x
    Apr 24, 2019 at 12:07
  • 1
    here is your problem: result.linkName = '/'+record.Id; you should assign the record and not the list: record.linkName = '/'+record.Id;
    – Mo Hamada
    Apr 24, 2019 at 12:45
  • Feeling like an idiot now, anyway, thank you so much!
    – gs650x
    Apr 24, 2019 at 13:42
  • 1
    happens! mark it as solved, if your problem ist solved.
    – Mo Hamada
    Apr 24, 2019 at 15:08

You must log in to answer this question.

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