In my previous post we have seen how to open record detail page directly from the lightning data table .If the same thing you wants to do it in Classic Console where your visual force is loading the LWC component then that will not work.
Please do the below changes to work the same in Classic console as well.The major change involves at Url param and target param in columns section.
Change the target attribute to '_top' and append the console#%2F in the redirection url
AccountListTable.js
Please do the below changes to work the same in Classic console as well.The major change involves at Url param and target param in columns section.
Change the target attribute to '_top' and append the console#%2F in the redirection url
AccountListTable.js
import { LightningElement ,wire,track} from 'lwc'; import getAllOpps from '@salesforce/apex/GetAllAccountsCntrl.getAllAccounts'; export default class AccountListTable extends LightningElement { @track columns = [ { label: 'Account Name', fieldName: 'nameUrl', type: 'url', typeAttributes: {label: { fieldName: 'Name'}, target: '_top'}, sortable: true }, { label: 'Account Source', fieldName: 'AccountSource', type: 'text', }, { label: 'Website', fieldName: 'Website', type: 'text', }, { label: 'Close date', fieldName: 'closeDate', type: 'date', } ]; @track error; @track listAccsData = []; @wire(getAllAccounts) wiredAllAccounts({ error, data }) { if (data) { this.listAccsData = data.map(record => Object.assign( { "nameUrl": '/console#%2F'+record.Id},
record )); } else if (error) { this.error = error; this.listAccsData = null; } } }
Did not working this link in my code please help me
ReplyDeleteMy Code:
-------
{
label: 'Subject',
fieldName: 'nameUrl',
type: 'url',
typeAttributes: {label: { fieldName: 'Subject' },
target: '_blank'},
sortable: true
},
@wire(getactivities,{recordId: '$recordId'})
openactivities(result) {
this.refreshTable = result;
if (result.data) {
this.data = result.data;
this.error = undefined;
this.data = result.data.map(record => Object.assign(
{ "nameUrl": '/lightning/r/Task/'+record.Id},
record
));
} else if (result.error) {
this.error = result.error;
this.data = undefined;
}
}
This peace of code is to open the hyperlink in the classic console not in the lightning console or lightning experience. If your trying in lightning please share the what is the error your getting in console logs on click of hyperlink.
DeleteHow can i call lightning record page
ReplyDelete