• Raju Chi 5
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 4
    Replies
Hi Team,

Please help me how to write test class for below helper.
public class Risk_Waiver_Aggreement_TriggerHelper {
    
             
    // Populating RWA number to all child ERP device data using below method.

    Public  void updateParentRWA(List<Agreement__c> AgList){       
        List<Device__c> erplst = [SELECT Name, RWA__c,Base_Device__c,Customer_Short_Name__c,RWA_Single_Record__c,Base_Device_Unique_Name__c,Product_Family_Unique_Name__c FROM Device__c
                                      where Base_Device_Unique_Name__c=: AgList[0].Base_Device_Unique_Name__c or Product_Family_Unique_Name__c=: AgList[0].Product_Family_Unique_Name__c 
                                      or Customer_Short_Name__c =: AgList[0].Account_Short_Name__c];
        system.debug('erplst'+erplst.size());
        Device__c erprecord = [select id,RWA__c  from Device__c where id =:AgList[0].Device__c limit 1];
        List<Device__c> erplist = new List<Device__c>();
        
        for (Agreement__c rw : AgList){           
            for(Device__c erp : erplst) {
                if(rw.status__c == 'Submitted'){
                if(rw.Apply_RWA_All_Base_Device__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'Yes' && rw.Apply_RWA_All_Product_family__c =='No'){
                    if(rw.Base_Device_Unique_Name__c == erp.Base_Device_Unique_Name__c){
                        erp.RWA__c = rw.id;                        
                        erplist.add(erp);                        
                    }               
                } else{
                    if(rw.Apply_RWA_All_Base_Device__c == 'No' && rw.Expose_RWA_to_Customer__c == 'Yes' && rw.Apply_RWA_All_Product_family__c =='Yes'){
                        if(rw.Product_Family_Unique_Name__c == erp.Product_Family_Unique_Name__c){
                            erp.RWA__c = rw.id;                             
                            erplist.add(erp);
                            
                        }
                    }else if(rw.Apply_RWA_All_Base_Device__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'No' && rw.Apply_RWA_All_Product_family__c =='No'){
                        if(rw.Base_Device_Unique_Name__c == erp.Base_Device_Unique_Name__c){
                            erp.RWA__c = rw.id;                           
                            erplist.add(erp);
                        }
                    }else if(rw.Apply_RWA_All_Base_Device__c == 'No' && rw.Expose_RWA_to_Customer__c == 'No' && rw.Apply_RWA_All_Product_family__c =='Yes'){
                        if(rw.Product_Family_Unique_Name__c == erp.Product_Family_Unique_Name__c){
                            erp.RWA__c = rw.id;                           
                            erplist.add(erp);
                        }
                    }
                }
            }
            }
            if(rw.Status__c == 'Submitted'){
            if(rw.Apply_RWA_All_Base_Device__c == 'No' && rw.Expose_RWA_to_Customer__c == 'No' && rw.Apply_RWA_All_Product_family__c =='No'){
                erprecord.RWA__c = rw.id;                
                erplist.add(erprecord);
            }else If(rw.Apply_RWA_All_Base_Device__c == 'No' && rw.Expose_RWA_to_Customer__c == 'yes' && rw.Apply_RWA_All_Product_family__c =='No'){
                erprecord.RWA__c = rw.id;                
                erplist.add(erprecord);
            }
        }

        } 
        
        
        try{
            if(erplist.size()>0){
                update erplist;
            }
            
        }catch(Exception ex){ 
            system.debug(ex);                  
        }      
    } 
    // This method is updating child part number into RWA record to show the RWA form page.
    public void updateERPPartNumber(List<Agreement__c> AgList){
        String concatenateString = '';
        List<Agreement__c> rwlist = new List<Agreement__c>();
        List<Device__c> erplst = [SELECT Name,Part_Number__c,Device__r.Tapeout_Type__c,Device__r.Name   FROM Device__c where RWA__c =:AgList];
        String partnumber;
        for(Agreement__c rw : AgList){
           partnumber ='';
            system.debug('erplst'+erplst.size());
            for(Device__c erp : erplst){                
                If(rw.Apply_RWA_All_Base_Device__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'Yes' ){
                    concatenateString += String.isBlank(concatenateString) ? erp.Part_Number__c : ',' + erp.Part_Number__c;
                    
                    if(erp.Device__r.Tapeout_Type__c  == 'Single Product'){                         
                        partnumber = erp.Device__r.Name;
                        rw.Single_Product__c = true;
                    } 
                }else{
                    If(rw.Apply_RWA_All_Product_family__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'Yes' ){
                        concatenateString += String.isBlank(concatenateString) ? erp.Part_Number__c : ',' + erp.Part_Number__c; 
                        system.debug('concatenateString'+concatenateString);
                        
                    }
                }
                
            }
            rw.Initial_Part_Number_s_Covered__c = concatenateString;
            
            if( rw.Description_and_Part_Number__c != null && (rw.Description_and_Part_Number__c.contains(partnumber))){
                rw.Description_and_Part_Number__c = rw.Description_and_Part_Number__c;
            }else if(rw.Description_and_Part_Number__c == '' || rw.Description_and_Part_Number__c == null ){                
                rw.Description_and_Part_Number__c = partnumber;
            }else{
                 rw.Description_and_Part_Number__c = partnumber+ rw.Description_and_Part_Number__c;
            }
            
            rw.Customer_Product_Family_Name__c = true;
            
        }        
        
    }
    
    public void SendApprovalEmail(List<Agreement__c> AgList){
        
        
            string AccountTeamRoles = EnvironmentSettings.get('Account_Team_Roles');
            List<string> TeamRoles = AccountTeamRoles.split(',');
        
               
        List<string> toRecipients=new List<string>();
        List<string> ccAddresses=new List<string>();        
        Set<id> accid = new Set<id>();
        Id templateId; 
        
        templateId = [select id, name from EmailTemplate where developername = 'RWA_after_Approval_To_Proxy_Users'].id; 
        List<Agreement__c> rwList =[select id,ERP_Device__r.Device__r.Account__c from Agreement__c where id=:AgList];
        
        for(Agreement__c rw:rwList){
            if(rw.ERP_Device__r.Device__r.Account__c != null){
                accid.add(rw.ERP_Device__r.Device__r.Account__c);
                system.debug('accid'+accid);
            }
        }
         
         List<Account_Team__c> listofUsers = [Select Id,user__r.email,User__r.isActive,Team_Role__c,Account__c,User__c from Account_Team__c 
                                                 where (Team_Role__c in :TeamRoles) AND Account__c =:accid AND User__r.isActive = True];      
       
        system.debug('listofUsers'+listofUsers.size());
                
        for(Account_Team__c ATP : listofUsers){                                                           
            toRecipients.add(ATP.User__c);
           
            }
           List<Messaging.SingleEmailMessage > emailList = new list < Messaging.SingleEmailMessage>();
        for(Agreement__c rw:AgList){
            if(rw.Status__c  == 'Approved' && rw.Retrigger_to_ERP__c == false){
                Messaging.Singleemailmessage mail = new Messaging.Singleemailmessage();
                mail.settoAddresses(toRecipients);
                mail.setWhatId(rw.id);
                mail.saveAsActivity = false; 
                mail.setTemplateId(templateId);
                mail.setTargetObjectId(rw.OwnerId);               
                emailList.add(mail);
            }
             if (emailList.size() > 0) {
                Messaging.sendEmail(emailList);
             }
             
          
        }
         
    }
    Public void sharingRWAtoCSR(List<Agreement__c> AgList){
          
         Set<id> accid = new Set<id>();       
            string AccountTeamRoles = EnvironmentVariable.get('CSR Sharing Settings');       
          List<string> TeamRoles = AccountTeamRoles.split(',');
       
        
        List<Agreement__c> rwList =[select id,ERP_Device__r.Device__r.Account__c from Agreement__c where id=:AgList];
        for(Agreement__c rw:rwList){
            if(rw.ERP_Device__r.Device__r.Account__c != null){
                accid.add(rw.ERP_Device__r.Device__r.Account__c);
              
            }
        }
        //Get the CER users from Account team proxy with same account rw.ERP_Device__r.Device__r.Account__c 
        List<Account_Team__c> listofUsers = [Select Id,user__r.email,User__r.isActive,Team_Role__c,Account__c,User__c from Account_Team__c 
                                                 where (Team_Role__c in :TeamRoles) AND Account__c =:accid AND User__r.isActive = True]; 
        
        
        // Share record to RWA (Agreement__Share)
        List<Agreement__Share> sharerwa = new List<Agreement__Share>();
        for(Agreement__c Rwa:AgList){
            for(Account_Team__c ATP : listofUsers){ 
              Agreement__Share rec = new Agreement__Share();
                        rec.AccessLevel = 'Edit';
                        rec.ParentId = Rwa.id;                        
                        rec.UserOrGroupId = ATP.User__c;
                        sharerwa.add(rec);
            }
            
                        
        }
        try{
            if(sharerwa.size()>0){
                insert sharerwa;
            }
            
        }catch(Exception e){
            system.debug(e);
        }
          
    }
   
    
}

Thanks in advance,
Raj
Hi All,

I have a requirement like child Part number update to Parent object field with comma separeted.

But issue is when status is approved then i have populated Parent id to child data with some creteria.when updating part number using before update part number is not populated in parent object  because child data is not adding before commit.

When using after update getting record is read only.

Here is code.

public  void updatePartNumber1(List<Account> rwlist){
        if(isCheck == true){
        String concatenateString = '';
        
         List<Contact> erplst = [SELECT Name,Part_Number__c,Device__r.Type__c,Device__r.Name   FROM Contact where account__c =:rwlist];
        String partnumber;
        for(Account  rw : rwlist){
            
           partnumber ='';
            system.debug('erplst'+erplst.size());
            if(rw.status__c == 'Approved' ){
            for(Contact erp : erplst){ 
               
                If(rw.Apply_RWA_All_Base_Device__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'Yes' ){
                    concatenateString += String.isBlank(concatenateString) ? erp.Part_Number__c : ',' + erp.Part_Number__c;
                    
                    if(erp.Device__r.Tapeout_Type__c  == 'Single Value'){
                        
                        partnumber = erp.Device__r.Name;
                        rw.Single_Product__c = true;
                    } 
                }else{
                    If(rw.Apply_RWA_All_Product_family__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'Yes' ){
                        concatenateString += String.isBlank(concatenateString) ? erp.Part_Number__c : ',' + erp.Part_Number__c; 
                        system.debug('concatenateString'+concatenateString);
                        
                    }
                }
                
            }
            rw.Initial_Part_Number_s_Covered__c = concatenateString;
            
            if( rw.Description_and_Part_Number__c != null && (rw.Description_and_Part_Number__c.contains(partnumber))){
                rw.Description_and_Part_Number__c = rw.Description_and_Part_Number__c;
            }else if(rw.Description_and_Part_Number__c == '' || rw.Description_and_Part_Number__c == null ){                
                rw.Description_and_Part_Number__c = partnumber;
            }else{
                 rw.Description_and_Part_Number__c = partnumber+ rw.Description_and_Part_Number__c;
            }
            
            rw.Customer_Product_Family_Name__c = true;
            rwlist.add(rw);
            }   
        }
        try{
            update rwlist;
        }catch(exception e){
            system.debug(e);
        }
        }
    }
 
Hi All,

I have created visual force page with custom controller. 

function is: we are displaying contact eamil list in custom page and when user select conatct email list and click on button user receving emails resepctive contacts. 

When i am testing for system adming emails are sending to contacts but when testing spaecific profile emails are not receiving for conatcts.

Checked email logs : emails are generated And showing 'D' and 'R'

Please let me know what could be the problem here.

Regards,
Raj

 
Hi,

Could you please let know how to create below table in vf email templete.

Regards,
RajUser-added image
Hi,
How to write test class for below class.

global class RecordAttachmentValidate {
    
   @AuraEnabled public static List<ContentDocumentLink> ContentDocumentList{get;set;}
    @AuraEnabled
    webservice static void ValidateAttachment(String RecordID){
       
        
       ContentDocumentList=[SELECT Id FROM ContentDocumentLink where LinkedEntityId =:RecordID];
        system.debug('ContentDocumentList'+ContentDocumentList);
        try{                   
            
            if(ContentDocumentList.size() !=0){               
                Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                req1.setComments('Submitting request for approval automatically using Trigger');
                req1.setObjectId(RecordID);                   
                Approval.ProcessResult result = Approval.process(req1);
            } else{                
                throw new AuraHandledException('Please add attchments');

            }            
        }catch(Exception e){
            throw new AuraHandledException(e.getMessage());
            //return null;      
        }
        
    }
}
Hi Team,

I have requirement like before click on submit for approval button validate attachemnt is present or not for custom object.

If attachment is not there then show the error message otheriwse submit for the approval.

how to achive this using custom lightning component button withour using trigger.

Regards,
Raj
Hi 

I have created lightning:recordEditform and recordform lightning component, and inside component i have Approve button.

When click on approve button back end i need to update status filed as Approved and render to Edit form to View Form.
<lightning:recordEditForm recordId="{!v.RwaIDFromVfPage}" 
                              objectApiName="Order" 
                              aura:id="recordHandler"
                               onload="{!c.handleLoad}"
                              onsuccess="{!c.handleSuccess}"
                              onsubmit="{!c.handleSubmit}">
         
        <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" onclick="{!c.approveMethod}" />
            <!-- <lightning:button type="button" name="Reassign" label="Reassign" />   -->         
            <lightning:button type="button" variant="neutral" label="Cancel" title="Cancel" onclick="{!c.handleCancel}" />
            
        </div>  

 approveMethod: function (component, event, helper) {
       // var action= component.get("c.Form");
        console.log("abcd");
    /*  event.preventDefault(); //Prevent default submit
        var eventFields = event.getParam("fields"); //get the fields\
        console.log("qwefrty"+eventFields);
        eventFields["Status__c"] = 'Approved'; //Add Description field Value
        console.log('hiii'+ eventFields["Status__c"]);
        component.find('RWAForm').submit(eventFields); */
        
      
         var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
        $A.enqueueAction(action);
        
    },

Please let me know how to handle this.
Hi Team,

I want to generate pdf page using lightning component inside vf page.
I have tried using below code but showing empty pdf file. could please help on this.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="sendData" type="object"/>

    <lightning:recordViewForm recordId="{!v.recordId}" objectApiName="Account">
       
            
       
       
         <div class="slds-wrap slds-text-align_center">
        <lightning:button aura:id="printButton" class="topMargin noPrint" label="Print In Pdf" onclick="{!c.downloadDocument}" />
        </div>
         <div class="slds-wrap slds-text-align_center">
            RWA FORM
        </div>
        <table  class="slds-table slds-table_bordered slds-table_cell-buffer">
            <div class="slds-grid slds-gutters">
                <div class="slds-col">
                    <span>Account##</span>
                </div>
                <div class="slds-col">
                    <span> <lightning:outputField variant="label-hidden" fieldName="Name" /></span>
                </div>
                <div class="slds-col">
                    <span>Effective date</span>
                </div>
                <div class="slds-col">
                    <span><lightning:outputField variant="label-hidden" fieldName="Effective_Date__c" /></span>
                </div>
            </div>
            <br/>
        </table>
        <br/>    
    </lightning:recordViewForm>   
</aura:component>

({
    downloadDocument : function(component, event, helper) {
           
        var sendDataProc = component.get("v.sendData");
        var dataToSend = {
           
            "label" : "This is test"
        }; //this is data you want to send for PDF generation
        
        //invoke vf page js method
        sendDataProc(dataToSend, function(){
          window.print();
        });
         
    }
    
})

Page1:

<apex:page controller="DataDisplayController" showHeader="false">
    <apex:includeLightning />
    
    <!-- Page code -->
    <apex:form >
        <apex:inputhidden id="hidData" value="{!PDFData}"/>
    
        <apex:actionfunction name="jsGeneratePDF" action="{!downloadPDF}" />
        
        <div id="lightning" />
        
    <script>
        function saveData(data, callback){
            var hidData = document.getElementById('{!$Component.hidData}');
            hidData.value = JSON.stringify(data);
            
            //invoke PDF Generation
            jsGeneratePDF();
         
            //invoke callback;
            if(typeof callback == 'function') callback();
        }
        
        
        function loadComponents(){
            console.log("Loading lightning component: DataProcessor");
            
            $Lightning.use("c:test", function() {
                $Lightning.createComponent("c:AccountViewForm",
                { 
                    sendData : saveData
                },
                "lightning",
                function(cmp) {
                    // do some stuff
                });
            });
        }
        
        loadComponents();
    </script>
    </apex:form> 
   
</apex:page>

Page2:
<apex:page controller="DataDisplayController" showHeader="false">
    <apex:includeLightning />
    
    <!-- Page code -->
    <apex:form >
        <apex:inputhidden id="hidData" value="{!PDFData}"/>
    
        <apex:actionfunction name="jsGeneratePDF" action="{!downloadPDF}" />
        
        <div id="lightning" />
        
    <script>
        function saveData(data, callback){
            var hidData = document.getElementById('{!$Component.hidData}');
            hidData.value = JSON.stringify(data);
            
            //invoke PDF Generation
            jsGeneratePDF();
         
            //invoke callback;
            if(typeof callback == 'function') callback();
        }
        
        
        function loadComponents(){
            console.log("Loading lightning component: DataProcessor");
            
            $Lightning.use("c:test", function() {
                $Lightning.createComponent("c:AccountViewForm",
                { 
                    sendData : saveData
                },
                "lightning",
                function(cmp) {
                    // do some stuff
                });
            });
        }
        
        loadComponents();
    </script>
    </apex:form> 
   
</apex:page>
controller:
public class DataDisplayController {
    public String PDFData {get; set;} 
    
    public DataDisplayController(){
       // PDFData = '';
    }
    
    public PageReference downloadPDF(){
        System.PageReference pageRef = new System.PageReference('/apex/AccountPdfPage');
        
        //ensure pdf downloads and is assigned with defined name
        pageRef.getHeaders().put('content-disposition', 'attachment; filename=RWAForm.pdf');
        
        return pageRef;
    }
}

Regards,
Raju
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.

 
Hi All,

I have a requirement like child Part number update to Parent object field with comma separeted.

But issue is when status is approved then i have populated Parent id to child data with some creteria.when updating part number using before update part number is not populated in parent object  because child data is not adding before commit.

When using after update getting record is read only.

Here is code.

public  void updatePartNumber1(List<Account> rwlist){
        if(isCheck == true){
        String concatenateString = '';
        
         List<Contact> erplst = [SELECT Name,Part_Number__c,Device__r.Type__c,Device__r.Name   FROM Contact where account__c =:rwlist];
        String partnumber;
        for(Account  rw : rwlist){
            
           partnumber ='';
            system.debug('erplst'+erplst.size());
            if(rw.status__c == 'Approved' ){
            for(Contact erp : erplst){ 
               
                If(rw.Apply_RWA_All_Base_Device__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'Yes' ){
                    concatenateString += String.isBlank(concatenateString) ? erp.Part_Number__c : ',' + erp.Part_Number__c;
                    
                    if(erp.Device__r.Tapeout_Type__c  == 'Single Value'){
                        
                        partnumber = erp.Device__r.Name;
                        rw.Single_Product__c = true;
                    } 
                }else{
                    If(rw.Apply_RWA_All_Product_family__c == 'Yes' && rw.Expose_RWA_to_Customer__c == 'Yes' ){
                        concatenateString += String.isBlank(concatenateString) ? erp.Part_Number__c : ',' + erp.Part_Number__c; 
                        system.debug('concatenateString'+concatenateString);
                        
                    }
                }
                
            }
            rw.Initial_Part_Number_s_Covered__c = concatenateString;
            
            if( rw.Description_and_Part_Number__c != null && (rw.Description_and_Part_Number__c.contains(partnumber))){
                rw.Description_and_Part_Number__c = rw.Description_and_Part_Number__c;
            }else if(rw.Description_and_Part_Number__c == '' || rw.Description_and_Part_Number__c == null ){                
                rw.Description_and_Part_Number__c = partnumber;
            }else{
                 rw.Description_and_Part_Number__c = partnumber+ rw.Description_and_Part_Number__c;
            }
            
            rw.Customer_Product_Family_Name__c = true;
            rwlist.add(rw);
            }   
        }
        try{
            update rwlist;
        }catch(exception e){
            system.debug(e);
        }
        }
    }
 
Hi,
How to write test class for below class.

global class RecordAttachmentValidate {
    
   @AuraEnabled public static List<ContentDocumentLink> ContentDocumentList{get;set;}
    @AuraEnabled
    webservice static void ValidateAttachment(String RecordID){
       
        
       ContentDocumentList=[SELECT Id FROM ContentDocumentLink where LinkedEntityId =:RecordID];
        system.debug('ContentDocumentList'+ContentDocumentList);
        try{                   
            
            if(ContentDocumentList.size() !=0){               
                Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                req1.setComments('Submitting request for approval automatically using Trigger');
                req1.setObjectId(RecordID);                   
                Approval.ProcessResult result = Approval.process(req1);
            } else{                
                throw new AuraHandledException('Please add attchments');

            }            
        }catch(Exception e){
            throw new AuraHandledException(e.getMessage());
            //return null;      
        }
        
    }
}
Hi 

I have created lightning:recordEditform and recordform lightning component, and inside component i have Approve button.

When click on approve button back end i need to update status filed as Approved and render to Edit form to View Form.
<lightning:recordEditForm recordId="{!v.RwaIDFromVfPage}" 
                              objectApiName="Order" 
                              aura:id="recordHandler"
                               onload="{!c.handleLoad}"
                              onsuccess="{!c.handleSuccess}"
                              onsubmit="{!c.handleSubmit}">
         
        <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" onclick="{!c.approveMethod}" />
            <!-- <lightning:button type="button" name="Reassign" label="Reassign" />   -->         
            <lightning:button type="button" variant="neutral" label="Cancel" title="Cancel" onclick="{!c.handleCancel}" />
            
        </div>  

 approveMethod: function (component, event, helper) {
       // var action= component.get("c.Form");
        console.log("abcd");
    /*  event.preventDefault(); //Prevent default submit
        var eventFields = event.getParam("fields"); //get the fields\
        console.log("qwefrty"+eventFields);
        eventFields["Status__c"] = 'Approved'; //Add Description field Value
        console.log('hiii'+ eventFields["Status__c"]);
        component.find('RWAForm').submit(eventFields); */
        
      
         var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
        $A.enqueueAction(action);
        
    },

Please let me know how to handle this.
Hi Team,

I want to generate pdf page using lightning component inside vf page.
I have tried using below code but showing empty pdf file. could please help on this.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="sendData" type="object"/>

    <lightning:recordViewForm recordId="{!v.recordId}" objectApiName="Account">
       
            
       
       
         <div class="slds-wrap slds-text-align_center">
        <lightning:button aura:id="printButton" class="topMargin noPrint" label="Print In Pdf" onclick="{!c.downloadDocument}" />
        </div>
         <div class="slds-wrap slds-text-align_center">
            RWA FORM
        </div>
        <table  class="slds-table slds-table_bordered slds-table_cell-buffer">
            <div class="slds-grid slds-gutters">
                <div class="slds-col">
                    <span>Account##</span>
                </div>
                <div class="slds-col">
                    <span> <lightning:outputField variant="label-hidden" fieldName="Name" /></span>
                </div>
                <div class="slds-col">
                    <span>Effective date</span>
                </div>
                <div class="slds-col">
                    <span><lightning:outputField variant="label-hidden" fieldName="Effective_Date__c" /></span>
                </div>
            </div>
            <br/>
        </table>
        <br/>    
    </lightning:recordViewForm>   
</aura:component>

({
    downloadDocument : function(component, event, helper) {
           
        var sendDataProc = component.get("v.sendData");
        var dataToSend = {
           
            "label" : "This is test"
        }; //this is data you want to send for PDF generation
        
        //invoke vf page js method
        sendDataProc(dataToSend, function(){
          window.print();
        });
         
    }
    
})

Page1:

<apex:page controller="DataDisplayController" showHeader="false">
    <apex:includeLightning />
    
    <!-- Page code -->
    <apex:form >
        <apex:inputhidden id="hidData" value="{!PDFData}"/>
    
        <apex:actionfunction name="jsGeneratePDF" action="{!downloadPDF}" />
        
        <div id="lightning" />
        
    <script>
        function saveData(data, callback){
            var hidData = document.getElementById('{!$Component.hidData}');
            hidData.value = JSON.stringify(data);
            
            //invoke PDF Generation
            jsGeneratePDF();
         
            //invoke callback;
            if(typeof callback == 'function') callback();
        }
        
        
        function loadComponents(){
            console.log("Loading lightning component: DataProcessor");
            
            $Lightning.use("c:test", function() {
                $Lightning.createComponent("c:AccountViewForm",
                { 
                    sendData : saveData
                },
                "lightning",
                function(cmp) {
                    // do some stuff
                });
            });
        }
        
        loadComponents();
    </script>
    </apex:form> 
   
</apex:page>

Page2:
<apex:page controller="DataDisplayController" showHeader="false">
    <apex:includeLightning />
    
    <!-- Page code -->
    <apex:form >
        <apex:inputhidden id="hidData" value="{!PDFData}"/>
    
        <apex:actionfunction name="jsGeneratePDF" action="{!downloadPDF}" />
        
        <div id="lightning" />
        
    <script>
        function saveData(data, callback){
            var hidData = document.getElementById('{!$Component.hidData}');
            hidData.value = JSON.stringify(data);
            
            //invoke PDF Generation
            jsGeneratePDF();
         
            //invoke callback;
            if(typeof callback == 'function') callback();
        }
        
        
        function loadComponents(){
            console.log("Loading lightning component: DataProcessor");
            
            $Lightning.use("c:test", function() {
                $Lightning.createComponent("c:AccountViewForm",
                { 
                    sendData : saveData
                },
                "lightning",
                function(cmp) {
                    // do some stuff
                });
            });
        }
        
        loadComponents();
    </script>
    </apex:form> 
   
</apex:page>
controller:
public class DataDisplayController {
    public String PDFData {get; set;} 
    
    public DataDisplayController(){
       // PDFData = '';
    }
    
    public PageReference downloadPDF(){
        System.PageReference pageRef = new System.PageReference('/apex/AccountPdfPage');
        
        //ensure pdf downloads and is assigned with defined name
        pageRef.getHeaders().put('content-disposition', 'attachment; filename=RWAForm.pdf');
        
        return pageRef;
    }
}

Regards,
Raju