salesforce点击classic按钮调用lightning组件

news/2024/5/18 21:38:01 标签: salesforce, apex

创建按钮,选择visualforce 页面,然后创建visualforce页面。

how to Call a Lightning component from a Classic custom button
You can definitely call a Lightning Component from a Classic custom button. However, the process is not straightforward as Lightning components are not meant to be directly used in Salesforce Classic, but workarounds could be made to make them usable.

Here’s a sample process of doing this:

  1. Create your Lightning Component. Please ensure that the component is globally accessible as we are going to use it outside the Lightning Environment. Also, ensure that you have added the component to a Lightning Application.

  2. Create a Visualforce Page to embed the line of code to include the Lightning component in the page. Here’s a sample code of how to do it:

<apex:page standardController="Account"> <!-- specify the object -->
  <apex:includeLightning />
  <div id="lightning" />

  <script>
    $Lightning.use("c:myLightningApp", function() {
      $Lightning.createComponent("c:myLightningComponent",
          { accountId : "{!Account.Id}" }, // pass record id to the component
          "lightning",
          function(cmp) {
            // do some extra stuff after component creation
          });
    });
  </script>
</apex:page>

*Note: c:myLightningApp refers to the Lightning Application that holds your component; and c:myLightningComponent refers to your Lightning Component.

  1. Save the Visualforce page, ensure it is available for use.

  2. Now, create a Classic custom button. In the button setup, choose ‘Display in new window’ as the behavior, and ‘URL’ as the content source, then in the URL field put in:

/apex/YourVisualforcePagename?Id={!Account.Id}

Replace “YourVisualforcePagename” with the actual API name of your visualforce page, and also replace “Account.Id” with the actual object id you are working with if not Account.

  1. After all these, save the button. You can add it to the layout of the object you are working with.

Please note this procedure works but is a workaround, Salesforce doesn’t support directly using Lightning Components in Salesforce Classic.

Also, make sure to test all scenarios before deploying it to production.


http://www.niftyadmin.cn/n/5073582.html

相关文章

OpenAI重大更新!为ChatGPT推出语音和图像交互功能

原创 | 文 BFT机器人 OpenAI旗下的ChatGPT正在迎来一次重大更新&#xff0c;这个聊天机器人现在能够与用户进行语音对话&#xff0c;并且可以通过图像进行交互&#xff0c;将其功能推向与苹果的Siri等受欢迎的人工智能助手更接近的水平。这标志着生成式人工智能运动的一个显著…

基于springboot实现汽车租赁管理系统项目演示【项目源码+论文说明】分享

基于springboot实现汽车租赁管理系统项目演示 摘要 随着社会的发展&#xff0c;计算机的优势和普及使得汽车租赁系统的开发成为必需。汽车租赁系统主要是借助计算机&#xff0c;通过对汽车租赁信息等信息进行管理。减少管理员的工作&#xff0c;同时也方便广大用户对个人所需汽…

Swagger使用详解

目录 一、简介 二、SwaggerTest项目搭建 1. pom.xml 2. entity类 3. controller层 三、基本使用 1. 导入相关依赖 2. 编写配置文件 2.1 配置基本信息 2.2 配置接口信息 2.3 配置分组信息 2.3.1 分组名修改 2.3.2 设置多个分组 四、常用注解使用 1. ApiModel 2.A…

Java异常:基本概念、分类和处理

Java异常&#xff1a;基本概念、分类和处理 在Java编程中&#xff0c;异常处理是一个非常重要的部分。了解如何识别、处理和避免异常对于编写健壮、可维护的代码至关重要。本文将介绍Java异常的基本概念、分类和处理方法&#xff0c;并通过简单的代码示例进行说明。 一、什么…

kubectl系列(六)-kubectl describe

要详细显示任意数量资源的状态&#xff0c;请使用该kubectl describe命令。默认情况下&#xff0c;输出还列出未初始化的资源。 1 查看有关特定节点的详细信息 kubectl describe nodes [node-name] 2 查看有关特定 Pod 的详细信息&#xff1a; kubectl describe pods [pod-…

网络安全(黑客)——自学篇

什么是网络安全&#xff1f; 网络安全可以基于攻击和防御视角来分类&#xff0c;我们经常听到的 “红队”、“渗透测试” 等就是研究攻击技术&#xff0c;而“蓝队”、“安全运营”、“安全运维”则研究防御技术。 无论网络、Web、移动、桌面、云等哪个领域&#xff0c;都有攻…

8051开发实例-实现红外寻迹小车

红外寻迹小车 文章目录 红外寻迹小车1、小车电路设计2、红外传感器电路设计3、代码实现Line Follower Robot 是一种基本机器人,它遵循由具有特定宽度的线(通常是浅色表面上的黑线)指示的特定路径。本文将详细介绍如何使用8051单片机实现一个简易的红外寻迹小车。 1、小车电路…

Android异步和线程

代码仓库&#xff1a;https://github.com/MADMAX110/Starbuzz Android应用打开数据库时首先要搜索数据库文件&#xff0c;如果没有找到数据库文件就要创建一个空的数据库。然后它要运行所有SQL命令&#xff0c;在数据库中创建数据库表和需要的所有初始数据。最后还要执行一些查…