0

I am working on a custom template picker component which filters/restricts templates available to users. The email form is in a child object which the template picker writes to using an aura method. The available templates are listed in the component in an aura:iteration as follows:

<aura:iteration items="{!v.emailTemplates}" var="emailTemplate">
    <a class="emailTemplate-name" onclick="{!c.fillFromTemplate}" data-subject="{!emailTemplate.Subject}" data-body="{!emailTemplate.body}" data-sfid="!emailTemplate.Id}"> 
    {!emailTemplate.DeveloperName}
    </a>
</aura:iteration>

However, I haven't been able to pass the emailTemplate body attribute, a text area/blob, which arrives at the controller as "undefined." I tried passing the entire record, but it arrives at the controller stringified as [object Object]. What's the best way to fill in my email body form with the template text and code once a user clicks on a template link? I could just retrieve the emailTemplate Name and ID and then make a second SOQL query to retrieve the emailTemplate Body but this seems inefficient.

Thanks in advance for your help.

2

JavaScript, and therefore Lightning, is cAsE-sEnSiTiVe. The correct field name is Body, not body.

<a class="emailTemplate-name" 
   onclick="{!c.fillFromTemplate}" 
   data-subject="{!emailTemplate.Subject}" 
   data-body="{!emailTemplate.Body}" 
   data-sfid="{!emailTemplate.Id}"> 
  • @Cleverlemming You're welcome! – sfdcfox Jan 14 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.