2

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">
    <tr>
        <td>DocumentId</td>
        <td>Title</td>                
    </tr>
    <apex:repeat value="{!ContDocLinks}" var="f">
    <tr>
        <td>{!f.ContentDocumentId}</td>
        <td>{!f.ContentDocument.title}</td>              
    </tr>
    </apex:repeat>        
</table>

Class:

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;
}}

1 Answer 1

1

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" 
assignTo="{!relatedId}"/>
1
  • 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
    Commented Jul 25, 2018 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .