Salesforce篇——如何在lightning页面添加ListviewButton使用lwc组件

1.创建lwc组件,用于展示listview已选数据:

html:

html 复制代码
<template>
    <lightning-card title="Selected Records">
        <p>Selected Record IDs: {selectedIds}</p>
        <lightning-button label="返回" onclick={goBack}></lightning-button>
    </lightning-card>
</template>

JS:

javascript 复制代码
import { LightningElement, api, track } from 'lwc';

export default class MyFlowHandlerComponent extends LightningElement {
    @api selectedIds; // 从 Flow 传递的记录 ID

    // 当组件加载时处理记录 ID
    connectedCallback() {
        console.log('Selected Record IDs: ', this.selectedIds);
        // 可以在这里处理记录 ID,例如展示或进一步操作
    }

    goBack(){
        setTimeout(
            function(){
                window.history.back();
            },1000
        );
    }
}

meta.xml:

XML 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>61.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__Tab</target>
        <target>lightning__FlowScreen</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property name="selectedIds" type="String[]"></property>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

2.创建screen flow

创建Collection Variables,命名必须是ids,否则拿不到selected ids

创建screen,并且选择对应的lwc组件,在lwc组件meta.xml中配置的property默认选择前面创建的variable :

保存并active

3.创建list view button:

在listview button layout中选择使用:

回到相关列表选择记录:

点击list view按钮,lwc组件拿到recordId:

相关推荐
胡萝卜术18 小时前
当大模型遇上浏览器:用 React + WebGPU 在前端跑通 DeepSeek-R1 的实战笔记
前端·javascript·面试
不好听61318 小时前
Tailwind CSS 原子化 CSS 完全入门:为什么现代前端开发都在用?
前端·css
人间凡尔赛18 小时前
Next.js 16 生产级实战:Cache Components + View Transitions 完整指南
开发语言·javascript·ecmascript
触底反弹18 小时前
🔥 React 零基础入门(上):环境搭建 + JSX 深度解析
前端·react.js·typescript
why技术18 小时前
分享一套我一直在使用的 AICoding 组合拳,小而美的典范。
前端·后端·ai编程
朦胧之19 小时前
AI应用-消费流式输出
前端·javascript·ai编程
小林ixn19 小时前
在浏览器跑通 15 亿参数大模型:我用 React + WebGPU 复刻了 DeepSeek-R1
前端·react.js·前端框架
Csvn19 小时前
容器查询 @container 实战:告别无休止的媒体查询
前端
谷哥的小弟21 小时前
TypeScript对象类型
javascript·typescript
稚南城才子,乌衣巷风流1 天前
函数:编程中的核心概念
开发语言·前端·javascript