i create lwc component, i select body from email template. i have error: null body.
public with sharing class SendInvoiceService { @AuraEnabled(cacheable=true) public static List getPreview(id contentVId){ return [SELECT Id, Title, FileExtension, ContentDocumentId From ContentVersion where id=:contentVId]; } @AuraEnabled(cacheable=true) public static SendInvoice__c getInvoice(id oppId) { Opportunity opp=[select id,Invoice_number__c, (select IsPrimary,Contact.Email,Contact.AccountId,Contact.FirstName,Contact.LastName from OpportunityContactRoles where IsPrimary=true) from Opportunity where id=:oppId]; OpportunityContactRole oppCR=opp.OpportunityContactRoles; SendInvoice__c invoice=new SendInvoice__c(); invoice.Body__c=[select body from EmailTemplate where name='OpportunityAndr'].body+' body'; return invoice; }}
sendInvoiceLWC.html
<template>
<lightning-card title="Send Invoice" >
<lightning-input label="EmailBody" value={realFormData.Body__c} if:true={realFormData} data-field="Subject"></lightning-input>
</lightning-card>
</template>
sendInvoiceLWC.js
import { LightningElement, api, wire } from 'lwc'; import getInvoice from '@salesforce/apex/SendInvoiceService.getInvoice'; import BODY_FIELD from '@salesforce/schema/SendInvoice__c.Body__c'; import { getSObjectValue } from '@salesforce/apex'; import { refreshApex } from '@salesforce/apex'; export default class sendInvoiceLWC extends NavigationMixin(LightningElement) { @api recordId; @api wiredContact; @api realFormData; @api InvoiceObj; @wire(getInvoice, { oppId:'$recordId' }) fetchedInvoice( resp){ this.wiredContact = resp; this.realFormData = this.wiredContact.data; this.InvoiceObj=resp; } get Subject() { return this.InvoiceObj.data?getSObjectValue(this.InvoiceObj.data, BODY_FIELD):'nothing'; } }