前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Salesforce 详细Page中自定义QuickAction Lightning Web Component应用

Salesforce 详细Page中自定义QuickAction Lightning Web Component应用

原创
作者头像
repick
发布2022-05-23 17:40:39
3780
发布2022-05-23 17:40:39
举报
文章被收录于专栏:Salesforce

详细page中的自定义Action,调用自定义组件时,现在可以支持使用Lwc,以下是QuickAction调用Lwc的例子

1.Lwc组件做成

quickActionForDelete.html

代码语言:javascript
复制
<template>
    <lightning-quick-action-panel header="Delete Opportunity">
        <lightning-card style="text-align:center;">
            <p class="title slds-text-heading--medium slds-hyphenate">
                Are you sure you want to delete this opportunity?
            </p>
        </lightning-card>
        &nbsp;
        <lightning-button onclick={handleDelete} variant="brand" label="削除" class="slds-m-right_x-small slds-no-flex text-right slds-float--right"></lightning-button>
        <lightning-button onclick={handleCancel} label="キャンセル" class="slds-m-right_x-small slds-no-flex text-right slds-float--right"></lightning-button>
    </lightning-quick-action-panel>
</template>

quickActionForDelete.js

代码语言:javascript
复制
import { LightningElement, api } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { CloseActionScreenEvent } from 'lightning/actions';

export default class QuickActionForDelete extends LightningElement {
    @api recordId;
    handleDelete(e) {
        // Close the modal window and display a success toast
        this.dispatchEvent(new CloseActionScreenEvent());
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: 'Opportunity Record Deleted!',
                variant: 'success'
            })
        );
    }

    handleCancel(e) {
        // Close the modal window and display a success toast
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}

quickActionForDelete.js-meta.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <description>QuickActionForDelete</description>
    <isExposed>true</isExposed>
    <masterLabel>QuickActionForDelete</masterLabel>
    <targets>
        <target>lightning__RecordAction</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
            <actionType>ScreenAction</actionType>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

2.QuickAction做成

3.PageLayout中添加QuickAction

4.测试

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.Lwc组件做成
  • 2.QuickAction做成
  • 3.PageLayout中添加QuickAction
  • 4.测试
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档