I'm working on making a Visualforce Email Template and I want to show all related Files related to a record. When I try saving out my Visualforce Component it gives the following error: 'Read only property 'c:compProdInitFiles.ContDocLinks''

I tried removing the 'set' from my class to make it read only but it still throws the error. Any ideas on how to fix? I would think this would be simple but can't resolve. Code is below. Thanks in advance!

Visualforce Component:

<apex:component controller="prodInitFiles" access="global">
<apex:attribute name="relatedId" type="Id" description="Id of the account" assignTo="{!ContDocLinks}"/>
<table border = "2" cellspacing = "5">
    <apex:repeat value="{!ContDocLinks}" var="f">


public class prodInitFiles {

public Id relatedId {get;set;}
public List<ContentDocumentLink> getContDocLinks()
    List<ContentDocumentLink> contDocLink;
    contDocLink = [SELECT ContentDocument.title, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId =: relatedId];
    return contDocLink;

The main issue is in this line assignTo="{!ContDocLinks}" attribute. The following code is correct one and it should be assignTo="{!relatedId}"

<apex:attribute name="relatedId" 
type="Id" description="Id of the account" 
  • I think calling 'relatedId' both times caused issues. I used the following: <apex:attribute name="relatedToId" type="Id" description="Id of the account" assignTo="{!relatedId}"/> Thanks! Now on to my next issue, the visualforce email template doesn't notice my filter on the Id. I'll post on another thread if I can't find the issue.
    – wadams2010
    Jul 25 '18 at 18:35

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.