LIGHTNING APP (Name: LightningCompForVFAPP)     Refrence Link:  https://www.sfdc-lightning.com/2019/07/how-to-call-vf-page-javascript-method.html Thanks And Regards , Suraj Tripathi.", "upvoteCount": 1, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4TnCSAV", "datePublished": "2021-04-19T09:08:01.000Z", "author": { "@type": "Person", "name": "Suraj Tripathi", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DARW3QAP", "affiliation": { "@type": "Organization", "name": "Cloud Analogy" } } } ] } } Skip to main content
How to add custom Cancel button in <Lightning:recordEditform> to navigate vf page when click on cancel button.

I tried myltiple ways but not navigating.

Please provide sameple code.

<lightning:recordEditForm recordId="{!v.RwaIDFromVfPage}" 

                              objectApiName="Risk_Waiver_Agreement__c" 

                              aura:id="recordHandler"

                               onload="{!c.handleLoad}"

                              onsubmit="{!c.handleSubmit}"

                              onsuccess="{!c.handleSuccess}"

                              

                              >

         

        <lightning:messages />

        <div class="slds-wrap slds-text-align_center">

            <lightning:button disabled="{!v.disabled}"  type="submit" name="save" label="Save" />

             <lightning:button   type="button" name="Approve" label="Approve" />

             <lightning:button   type="button" name="Reassign" label="Reassign" />            

            <lightning:button variant="neutral" label="Cancel" title="Cancel" type="text" onclick="{!c.handleCancel}" />

            

handleCancel : function (component, event, helper) {

    var urlEvent = $A.get("e.force:navigateToURL");

    urlEvent.setParams({

      "url": "/lightning/page/home"

    });

    urlEvent.fire();

},

And called above component from Vf page and to show the site.

 
답변 2개
  1. 2021년 4월 19일 오전 9:08
    Hi Raju,

    You can check that code you only have to change some code like change button to cancel and their event as well.

    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >

     <div>

        HI I AM COMPONENT AND I AM GETTING CALLED FROM VF.

        </div>

        <aura:attribute name="VfPageMethod" type="object"/>  <!--Attribute to take Vf page method-->

        <lightning:button label="Click me to pass message to VF page" onclick="{!c.doAction}"/>

    </aura:component>

    COMPONENT JS CONTROLLER

    ({

     doAction : function(component, event, helper) {

      var msgForVf="Hi This message was pass from component to me and I am VF page displaying this message";

            var vfMethod=component.get("v.VfPageMethod");

            // Calling Vf page method

            vfMethod(msgForVf,function()

                               {

         

                               });

     }

    })

    VISUALFORCE PAGE (Name: VfPageToCallLightningComp)

    <apex:page >

        <apex:includeLightning />

        <div  id="LightningCompContainer" />

       

        <script>

            $Lightning.use("c:LightningCompForVFAPP", function() {

                $Lightning.createComponent("c:LightningCompForVF", {

                VfPageMethod:getMessageFromComp,

                },

                "LightningCompContainer",

                function(cmp) {

                 

                });

            });

        function getMessageFromComp(compMsg)

        {

            alert(compMsg);

        }

        </script>

    </apex:page>

    LIGHTNING APP (Name: LightningCompForVFAPP)

    <aura:application access="GLOBAL" extends="ltng:outApp">

        <aura:dependency resource="c:LightningCompForVF"/>

    </aura:application>

    Refrence Link: https://www.sfdc-lightning.com/2019/07/how-to-call-vf-page-javascript-method.html

    Thanks And Regards ,

    Suraj Tripathi.
0/9000