function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prachi SPrachi S 

Visualforce Email Template Error : Unknown property 'VisualforceArrayList.Name error

Hi All,
I am getting "Unknown property 'VisualforceArrayList.Name" error while trying to create a Visualforce email template on custom object Status__c.
I have narrowed down the line that is actually giving me the error which is:
{!relatedTo.Demand_Vs_Supply_Master__r.Name}

I do not get this error when I change the line to display the ID instead of Name:
{!relatedTo.Demand_Vs_Supply_Master__c}

I have checked my relationship name is correct and cant figure out why it wont traverse to the related object.

Any help will be really appreciated.

Thank you!
 
<messaging:emailTemplate subject="{!relatedTo.Name} {!$Label.Incident_Submit_For_Approval}" 
recipientType="User" 
relatedToType="Status__c" 
language="{!recipient.LanguageLocaleKey}">
<messaging:htmlEmailBody >        
        <html>
            <body>
            <p>Hi {!relatedTo.Owner.Name},</p>
            <p>{!$Label.Incident_Submit_Approval_Request} {!relatedTo.Name}.</p>
            <p>{!relatedTo.Name} details :</p>
            
            <table cellspacing="0" cellpadding="0">
                <tr style="height: 21px;">
                    <td style="width: 130px;text-align: right;">Name</td>
                    <td style="padding-left: 10px;">{!relatedTo.Name}</td>
                </tr>                                             
                 <tr style="height: 21px;">
                    <td style="width: 130px;text-align: right;">Demand vs Supply</td>
                    <td style="padding-left: 10px;">{!relatedTo.Demand_Vs_Supply_Master__r.Name}</td>
                </tr>                                           
            </table>
            <p>You can either approve or reject by typing APPROVE or REJECT in the first line and adding comments in the second line in reply to this email.</p>
            <br/>Thank You,
            <!--<br/>{!relatedTo.Demand_Vs_Supply_Master__r.Supplier_Site__r.Site__r.Company__r.Name}.<br/>          -->
            </body>
        </html>
    </messaging:htmlEmailBody> 
</messaging:emailTemplate>



 
Best Answer chosen by Prachi S
sharathchandra thukkanisharathchandra thukkani
It'snot possible to get the master/lookup fields as merge fields in the email templates it is not possible in all kind of email templates.

work around would be you need to create the formula fields with the value of those cross object fields and use them as merge fields in the email templates.

All Answers

Manish BhatiManish Bhati
Did you verified whether the API name for Name in {!relatedTo.Demand_Vs_Supply_Master__r.Name} is correct?

As it could be {!relatedTo.Demand_Vs_Supply_Master__r.Name__c} , if the relationship is between custom objects.
Prachi SPrachi S
Name is the standard Name field on custom object Demand_Vs_Supply_Master__c.  
sharathchandra thukkanisharathchandra thukkani
It'snot possible to get the master/lookup fields as merge fields in the email templates it is not possible in all kind of email templates.

work around would be you need to create the formula fields with the value of those cross object fields and use them as merge fields in the email templates.
This was selected as the best answer
Prachi SPrachi S
Yes that works well! 

The object Demand_Vs_Supply_Master__c is a master object to another custom object Demand_Vs_Supply_Detail__c.
To validate your point I added a random lookup field in the Status__c object to another custom object Incident__c and used it as :
{!relatedTo.Incident__r.Name}
And this works without any issue!

Apparently any object that is part of a master-detail relationship cannot be used a merge field in email template.

Thank you  Sharathchandra thukkani.
Trilok PanwarTrilok Panwar
Hi All,

I am getting Error: Unknown property 'VisualforceArrayList.name' error while trying to create a Visualforce email template

Please check the code.
{!relatedTo.Intake_Form1__r.name}

It is throwing for only the Intake_Form1__c custom object, not getting for another object.

Please help.

Thanks,
Trilok