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
Imran MohammedImran Mohammed 

Does anyone know why aapex:outputField is not working in visualforce email template?

Hi,

 

I have seen a strange behavior using visualforce email template.

Earlier, i used apex:outputField in vf email template and it worked perfectly.

Now, when i tried to modify email emplate, below error message is shown

Error occurred trying to load the template for preview: Read access not found for <<Custom Object>>.

 

Does anyone know why is this happening?

 

ColinKenworthy2ColinKenworthy2

Sounds like someone amended the read access for that custom object in Profiles. Or possibly Field Level Security and/or Sharing Rules.

 

In any case I think your template saved OK, its just the preview that is broken.

Imran MohammedImran Mohammed

Thanks for the reply.

 

I have seen, nothing in profiles on that custom object has been change.

Even FLS has not been changed.

It used to work fine earlier  before the Winter'11 release.

 

I will suggest, you to create a sample email template and use apex:outputField on custom object  and see whether you are also getting the same error message.

 

Can you please respond back?

 

 

b-Forceb-Force

Hey,

I have use <apex:outPutText> tag successfully in brand new template

there is no such issue

 

Thanks,

Bala

kum09kum09

Hey Imran,

 

I just read your problem. It is the Read Permission problem only.  Try few things which I am mentioning below and try:

1) Go to the reffered profile - say System Admin or on whatever you are working on. Click Edit and go to the Object you are using and if any other related Object is also used check that also and see if it has Read Edit permissions or not. Or try selecting Modify All permissions for those objects and then try.

2) If everything is checked in above scenario and still it donot work, then go to Create -> objects -> Whatever Object You are using then go to field level Security and check the fields you are using in for Email Template, check the security and make Non Readable and visible and then try again.

 

Try these two things and I hope it will solve your issue.

 

Regards,

CKumar

Imran MohammedImran Mohammed

Thanks,

 

I tested it, the system admin has full permissions on all the custom objects as well as FLS settings set to true, but still the same error persists.

 

It will be of a great help if you can try out creating a sample vf email template and use apex:outputField and see whether you will succeed.

 

If you have any other suggestions, please let me know.

 

Anyway, thanks for your help.

kum09kum09

Can you send me the code of the VF template you have written? So that I can see what you are doing.

 

Regards,

Ckumar

Imran MohammedImran Mohammed

Below is the code,

Please let me know if anything is wrong.

 

<messaging:emailTemplate subject=" {!relatedTo.User_ID__r.name}" recipientType="User" relatedToType="Scon__c" >

<messaging:htmlEmailBody >

 

<html>

<body>

<p>Dear {!recipient.name},</p>

 

<table border="0">

<tr>

<td>

Number:

</td>

<td>

<apex:outputField value="{!relatedTo.Name}"/>

</td>

</tr>

<tr>

<td>

Name:

</td>

<td>

<apex:outputField value="{!relatedTo.Doc_Name__c}"/>

</td>

</tr>

<tr>

<td>

Date Generated:

</td>

<td>

<apex:outputField value="{!relatedTo.GDate__c}"/>

</td>

</tr>

<tr>

<td>

Date Viewed:

</td>

<td>

<apex:outputField value="{!relatedTo.DateViewed__c}"/>

</td>

</tr>

<tr>

<td>

Date Accepted:

</td>

<td>

<apex:outputField value="{!relatedTo.DateAccepted__c}"/>

</td>

</tr>

<tr>

<td>

Documents Accepted:

</td>

<td>

<apex:outputField value="{!relatedTo.Documents__c}"/>

</td>

</tr>

 

</table>

 

<br/>

<p>Thanks</p>

</body>

 

</html>

</messaging:htmlEmailBody>

</messaging:emailTemplate>

kum09kum09

Try using outputText instead of outputField

Imran MohammedImran Mohammed

Thanks for that.

 

I already replaced apex:outputField with outputText.

Can you tell why its not working?

kum09kum09

Try using single Name field and remove other fields from the html body, and then try again ?

kum09kum09

Hey Imran,

 

can you send your gmail id so that we can chat online and can resolve this issue ASAP?

 

Regards,

Ckumar