+ Start a Discussion
vinod fnuvinod fnu 

Javascript not passing the record id to controller class.

HTML
<template>
    <lightning-record-view-form record-id={recordId} object-api-name="obj__c">
    <div>
        {recordId}
    <lightning-button  variant="success" label="Invoice" onclick={handleclick}>
    </lightning-button>
    </div>
    </lightning-record-view-form>
    
</template>

JS
import { LightningElement,api,wire,track } from 'lwc';
import main from '@salesforce/apex/orderupdate.main';

export default class Invoicebutton extends LightningElement {
    @api recordId;
    @wire(main,{abf:'$recordId'})
    orders;
    handleclick(){
        main();
    }

}
    }

}

Controller
public with sharing class orderupdate {
    @AuraEnabled(cachable=true)
public static   void main(string abf){
        list<obj__c> ent=[select id,name,(select id,name from Accounts__r) from obj__C where id  =:abf];
        system.debug(ent);
}
The  debug statement is showing a null value on click of button no value is passed.
MagulanDuraipandianMagulanDuraipandian
Check the meta-xml file:

<?xml version="1.0" encoding="UTF-8"?>  
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="CaseEscalation">  
    <apiVersion>47.0</apiVersion>  
    <isExposed>false</isExposed>    
    <targets>      
        <target>lightning__RecordPage</target>      
    </targets>      
</LightningComponentBundle> 

Add console.log() statements in JavaScript to debug the issue.

--
Magulan Duraipandian
www.infallibletechie.com