Skip to main content

Hi all,

I have a LWC which I need to have an url cell in the datatable.

I used this code in getColumn function:

{ fieldName: 'Id', label: this.labels.Subject, type: 'url', typeAttributes: { label: { fieldName: 'Subject' }, linkify: true }, fixedWidth: 200, sortable: false, hideDefaultActions: true, wrapText: true }

it just give me something like:

http://0683O0000019fQvQAI

how can I simply attach the salesforce url into it?

thanks

 
1 answer
  1. Apr 6, 2021, 11:55 AM
    HII Hope

    Try The Below Code

    EXAMPLE:

    const columns = [{

    label: 'Id',

    fieldName: 'Id',

    },{

    label: "Name",

    fieldName: "recordLink",

    type: "url",

    sortable: true,

    editable: true,

    typeAttributes: { label: { fieldName: "Name" }, tooltip:"Name", target: "_blank" ,linkify: true},

    fixedWidth: 200, sortable: false, hideDefaultActions: true, wrapText: true

    }

    ];

    export default class TableFilterAndDelete extends LightningElement {

    @track showLoadingSpinner = true;

    error;

    data;

    recordId;

    records = '';

    columns = columns;

    wiredActivities;

    /*Calling Apex Class*/

    @wire(getOpps, {

    })

    wiredclass(value){

    this.wiredActivities = value;

    const { data, error } = value;

    if (data) {

    var ObjData = JSON.parse(JSON.stringify(data));

    this.records = ObjData.length;

    ObjData.forEach(Record => {

    Record.recordLink = "/" + Record.Id;

    Record.Name = Record.Name;

    });

    this.data = ObjData;

    this.showLoadingSpinner = false;

    this.error = undefined;

    } else if (error) {

    this.error = error;

    this.data = undefined;

    }

    }

    Please Mark it as Best Answer it Helps

    Thank You!