1

I am trying to generate the dynamic URL to redirect to record but it appends the id to the current page.

For example, I am getting this:

https://nishant-aishwarya-1234-dev-ed.lightning.force.com/lightning/page/0062w000003ar1dAAA/view

I want this:

https://nishant-aishwarya-1234-dev-ed.lightning.force.com/lightning/r/Opportunity/0062w000003ar1dAAA/view

Here is the code for the render function:

if (columnNames[i] == 'name') {
  columns.push({
    data: columnNames[i],
    title: columnNames[i],
    render: function(data, type, row, meta) {
      data = '<a href=' + row['id'] + '/view' + '>' + data + '</a>';
      return data;
    }
  });
}
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339

1 Answers1

0

Assuming that row['id'] holds only the 0062w000003ar1dAAA value, then you can change the URL so that it's relative to the site root:

render: function(data, type, row, meta) {
  return '<a href="/lightning/r/Opportunity/' + row['id'] + '/view">' + data + '</a>';
}

Or more succinctly:

render: (data, _, row) => '<a href="/lightning/r/Opportunity/' + row['id'] + '/view">' + data + '</a>'
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339