• salesforce点击classic按钮调用lightning组件


    创建按钮,选择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"> 
      <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>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    *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}
    
    • 1

    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.

  • 相关阅读:
    js实现pdf、word、excel、图片、html文件预览及下载
    如何通过提升客户体验带来更大的增长、更好的客户留存率?
    2022杭电多校(一)
    Pod详解
    一用就会的手机配音软件,效果好到你震惊~
    红黑树C++实现
    在idea中创建spring 微服务(boot)的Gradle项目 讲的很详细的
    Java基础~线程和进程(3) 多线程编程细节
    RabbitMQ消息确认机制
    【网络编程】套接字编程——UDP通信
  • 原文地址:https://blog.csdn.net/lycwhu/article/details/133090057