Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@liuxiachanghong
Created January 31, 2021 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuxiachanghong/a2675b44a3f55bdcf864c38787baf438 to your computer and use it in GitHub Desktop.
Save liuxiachanghong/a2675b44a3f55bdcf864c38787baf438 to your computer and use it in GitHub Desktop.
({
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'
}
});
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment