3

I have the following in an email template, which works:

<!-- template item display name -->
<apex:outputText rendered="{!NOT(ISBLANK(relatedTo.Template_Item_Displayname__c)) && NOT(kit)}" 
    value="{!$Label.Localized_Product_Description + ': ' + relatedTo.Template_Item_Displayname__c}" />
<c:NewLine rendered="{!NOT(ISBLANK(relatedTo.Template_Item_Displayname__c)) && NOT(kit)}" />
<apex:outputText rendered="{!NOT(ISBLANK(relatedTo.Parent_Serial__r.Template_Item_Displayname__c)) && kit}" 
    value="{!$Label.Localized_Product_Description + ': ' + relatedTo.Parent_Serial__r.Template_Item_Displayname__c}" />
<c:NewLine rendered="{!NOT(ISBLANK(relatedTo.Parent_Serial__r.Template_Item_Displayname__c)) && kit}" />

If I remove the last two parts, it errors:

<!-- template item display name -->
<apex:outputText rendered="{!NOT(ISBLANK(relatedTo.Template_Item_Displayname__c)) && NOT(kit)}" 
    value="{!$Label.Localized_Product_Description + ': ' + relatedTo.Template_Item_Displayname__c}" />
<c:NewLine rendered="{!NOT(ISBLANK(relatedTo.Template_Item_Displayname__c)) && NOT(kit)}" />

Error:

Error occurred trying to load the template for sending preview email: SObject row was retrieved via SOQL without querying the requested field: Serial_Number__c.Template_Item_Displayname__c. Please try editing your markup to correct the problem.

Here is the SOQL:

SELECT
    contact.Email,
    contact.Language_Code__c,
    contact.Name,
    license.Activation_Code__c,
    license.Entity_Id__c,
    license.Topcon_One_Created_By__r.Name,
    psn.Item_Number__r.Id,
    psn.Item_Number__r.Display_Name__c,
    psn.Dealer_Purchase_Order__c,
    psn.Email_Notification_Contacts__c,
    psn.Item_Description__c,
    psn.Name,
    psn.Product_Family__c,
    psn.Team__r.Name,
    psn.Template_Item_Displayname__c,
    psn.Template_Item_Number__c,
    psn.Topcon_Sales_Order__c,
    psn.Id,
    sn.Dealer_Purchase_Order__c,
    sn.Email_Notification_Contacts__c,
    sn.Item_Description__c,
    sn.Name,
    sn.Product_Family__c,
    sn.Team__r.Name,
    sn.Template_Item_Displayname__c,
    sn.Template_Item_Number__c,
    sn.Topcon_Sales_Order__c,
    Id // last for easy sorting
FROM
    License_Activation__c license,
    license.Serial_Number__r sn,
    sn.Parent_Serial__r psn,
    sn.End_User_Contact__r contact
WHERE Id IN :activationIds

I'm not sure how removing something would cause this error?

4
  • can you add the soql in the component's controller? Commented Jul 6, 2018 at 20:44
  • 1
    @veritacs assuming it's not a bug, it sounds like you're querying the field Template_Item_Displayname__c on parent_serial__r, but not at the relatedTo level Commented Jul 6, 2018 at 21:13
  • updated the SOQL. To be clear, the error happens if I remove outputText.
    – veritascs
    Commented Jul 6, 2018 at 21:28
  • i would try selective reduction and start with just the component, then add in each additional piece of markup
    – cropredy
    Commented Jul 7, 2018 at 2:18

0

You must log in to answer this question.

Browse other questions tagged .