You need to sign in to do that
Don't have an account?
How to trigger lightning:nagivation with 'open in a new tab' (or open in background tab)
Based on this project (https://trailhead.salesforce.com/ja/content/learn/projects/develop-account-geolocation-app-with-aura-components), I'm working on the aura components that lists the accounts and leads on google map and table compoents of those data, search with search terms and other parameters.
That works fine.
I want to tweak when I click the "view detail" button then open in a new tab (or open in background tab) instead of refreshing the same tab I was looking at. If anyone has any idea how to open in a new tab, please adivice.
I sense the issue is in the bottom part of the AccountListController.js
Thanks!
AccountListController.js
https://gist.github.com/liuxiachanghong/a2675b44a3f55bdcf864c38787baf438
({ onAccountsLoaded: function( component, event, helper ) { var accounts = event.getParam( 'accounts' ); if (accounts != null) { component.set( 'v.iconName', 'standard:account' ); component.set( 'v.listName', 'Account List' ); component.set( 'v.rows', event.getParam( 'accounts' ) ); var cols = [ { 'label': 'Name', 'fieldName': 'Name', 'initialWidth': 320, 'type': 'text' }, { 'label': 'Industry', 'fieldName': 'Industry', 'initialWidth': 190, 'type': 'text' }, { 'label': 'Type', 'fieldName': 'Client_Type_new__c', 'initialWidth': 100, 'type': 'text' }, { 'label': 'Owner', 'fieldName': 'Owner_Alias__c', 'initialWidth': 110, 'type': 'text' }, { 'label': 'Last', 'fieldName': 'Last_Sales_Activity_By__c', 'initialWidth': 110, 'type': 'text' }, { 'label': 'Last At', 'fieldName': 'Last_Sales_Activity__c', 'initialWidth': 110, 'type': 'date' }, { 'label': 'Last Won At', 'fieldName': 'Recent_Closed_Won_Date__c', 'initialWidth': 110, 'type': 'date' }, { 'label': 'Deal', 'fieldName': 'Related_Opportunities_y__c', 'type': 'currency' }, { 'label': 'Action', 'type': 'button', 'typeAttributes': { 'label': 'Details', 'name': 'view_details' } } ]; } else { component.set( 'v.iconName', 'standard:lead' ); component.set( 'v.listName', 'Lead List' ); component.set( 'v.rows', event.getParam( 'leads' ) ); var cols = [ { 'label': 'Name', 'fieldName': 'LastName', 'type': 'text' }, { 'label': 'Company', 'fieldName': 'Company', 'initialWidth': 320, 'type': 'text' }, { 'label': 'Prefecture', 'fieldName': 'State', 'type': 'text' }, { 'label': 'City', 'fieldName': 'City', 'type': 'text' }, { 'label': 'Street', 'fieldName': 'Street', 'initialWidth': 320, 'type': 'text' }, { 'label': 'Type', 'fieldName': 'Client_Type_new__c', 'type': 'text' }, { 'label': 'Owner', 'fieldName': 'Owner__c', 'type': 'text' }, { 'label': 'Action', 'type': 'button', 'typeAttributes': { 'label': 'Details', 'name': 'view_details' } } ]; } component.set( 'v.cols', cols ); }, onRowAction: function( component, event, helper ) { var accounts = event.getParam( 'accounts' ); var action = event.getParam( 'action' ); var row = event.getParam( 'row' ); if (accounts != null) { if ( action.name == 'view_details' ) { var navigation = component.find( 'navigation' ); navigation.navigate({ 'type': 'standard__recordPage', 'attributes': { 'objectApiName': 'Account', 'recordId': row.Id, 'actionName': 'view' } }); } } else { if ( action.name == 'view_details' ) { var navigation = component.find( 'navigation' ); navigation.navigate({ 'type': 'standard__recordPage', 'attributes': { 'objectApiName': 'Lead', 'recordId': row.Id, 'actionName': 'view' } }); } } } })
AccountList.cmp
https://gist.github.com/liuxiachanghong/705799f378c180a664cd70d52a13b58f
AccountsLoaded.event
https://gist.github.com/liuxiachanghong/c56f9b120ab6c60510db33b473aaeac7
Loop the SOQL results (accounts) and stores in rows, then set.
In the column section, setup the first columns that display Name while type 'url' and clickable as a link. Field name is linkName (relabel in type Attributes to the Name. This dones't open the window in the new tab nor background tab, but if you command (ctrl) click then it opens in a new background tab.
Solved.