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:

相关推荐
英俊潇洒美少年8 小时前
Vue 生产环境打包:SourceMap、压缩、混淆、加密全解 + 最佳实践
前端·javascript·vue.js
巴博尔8 小时前
UNIAPP中NVUE页面 动画
android·前端·javascript·ios·uni-app
猫头虎-前端技术9 小时前
JS 作用域与闭包:从变量提升到闭包陷阱的超详细解析
开发语言·javascript·云计算·bootstrap·ecmascript·openstack·perl
她说人狗殊途10 小时前
基于 vue-cli 创建
前端·javascript·vue.js
AZaLEan__11 小时前
前端移动端适配与 Bootstrap
前端·bootstrap·html
大家的林语冰11 小时前
Deno 2.8 正式发布,再次超越 Bun,史上最大的次版本升级诞生!
前端·javascript·node.js
渣渣xiong12 小时前
从零开始:前端转型AI agent直到就业第五十七天-第五十八天
前端·人工智能·python
影寂ldy12 小时前
C#数组的属性和方法(Clear / Copy / IndexOf )
开发语言·javascript·c#
Brave & Real12 小时前
小程序 const 在js中以及与同类的var和let之间的差异
javascript·微信小程序·小程序
AI周红伟12 小时前
周红伟:长鑫科技(CXMT)财务全景分析
前端·chrome·科技