Skip to main content

In Omnistudio, Create New ‘NavigateToListView’ Flexcard. Source Type is none.

Navigate To List View

Add Title using Text properties.

Navigate To List View

Now create New Apex class ‘RetrieveData‘ and Add this code.

Apex class
public class RetrieveData {
	@Auraenabled
    public static List<sobject> retrieveSobjectList(String query){
        return database.query(query);
    }
}

Now, create ‘NavigateToDeveloperName’ Lightning Web Component. And Add below code.

Navigate To Developer Name

navigateToDeveloperName.html

<template>
    <div class="btn-container navigatelist" onclick={handleNext}>
        {listOfTitle}
    </div>
</template>

navigateToDeveloperName.js

import { LightningElement, api } from 'lwc';
import { OmniscriptBaseMixin } from 'omnistudio/omniscriptBaseMixin';
import { NavigationMixin } from 'lightning/navigation';
import { getNamespaceDotNotation } from 'omnistudio/omniscriptInternalUtils';
import { OmniscriptActionCommonUtil } from 'omnistudio/omniscriptActionUtils';
import retrieveSobjectRecords from '@salesforce/apex/RetrieveData.retrieveSobjectList';
import template from './navigateToDeveloperName.html';
export default class NavigateToDeveloperName extends OmniscriptBaseMixin(NavigationMixin(LightningElement)) {
    _ns = getNamespaceDotNotation();
    _actionUtilClass;
    @api listDeveloperName;
    @api listViewId;
    @api listOfTitle;
    @api objectApiName;
    connectedCallback() {
        this._actionUtilClass = new OmniscriptActionCommonUtil();
    }
    render() {   
        return template;
    }
    handleNext() {
        console.log('btnclick');
        if(this.listViewId){
            this.handleListViewNavigation(this.listViewId);
        }
        else{
            retrieveSobjectRecords({ query : 'SELECT Id, Name, DeveloperName, SobjectType FROM ListView WHERE DeveloperName = \'' + this.listDeveloperName + '\' AND SobjectType =\'' + this.objectApiName + '\'' })
            .then(result => {
                if(result && result.length > 0){
                    this.handleListViewNavigation(result[0].Id);
                }
                else{
                    this.handleListViewNavigation('Recent');
                }
            })
            .catch(error => {
                console.error(error);
            })
        }
    }
    handleListViewNavigation(filterName) {
        // Navigate to the Accounts object's Recent list view.
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: this.objectApiName,
                actionName: 'list'
            },
            state: {
                filterName: filterName
            }
        });
    }
}

navigateToDeveloperName.css

/*navigateToDeveloperName.css*/
.btn-container {
    display: flex;
    justify-content: center;
}
.navigatelist {
    cursor: pointer;
    font-size: 20px;
}

navigateToDeveloperName.xml

<?xml version="1.0"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
	<apiVersion>57.0</apiVersion>
	<isExposed>true</isExposed>
	<runtimeNamespace>omnistudio</runtimeNamespace>
	<targets>
            <target>lightningCommunity__Page</target>
            <target>lightningCommunity__Default</target>
            <target>lightning__AppPage</target>
            <target>lightning__RecordPage</target>
            <target>lightning__HomePage</target>
        </targets>
</LightningComponentBundle>

Now, Create New child ‘ListOfAllAccount‘ Flexcard with no source

List Of All Account

In Child flexcard, Add custom Lwc and Pass 3 Attribute. And Activate this Flexcard.

Add custom Lwc and Pass Attribute

Now Add this ChildFlexcard to parent ‘NavigateToListView‘ Flexcard using child card properties.

Child Flexcard

Now add parent Flexcard (NavigateToListView) in Home page.

Lightning App Builder

here, when you click on this second Title All Account. you can redirect to All Account Listview page.

Home Page
Account List View

Thank you!! I hope this information is helpful for you.

 

Subscribe For More Updates

 

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!