+ Start a Discussion
dmchengdmcheng 

URLFOR error in Visualforce email template

hello.  I need to change a Visualforce email template written by someone else.  They included a URLFOR in the template.  Apparently it used to work, but now when I try to view the template in Setup, there is an error 

"Error occurred trying to load the template for preview: Invalid parameter for function URLFOR. Please try editing your markup to correct the problem"

I can edit and save the template, but I still see the error.

I created a basic template for testing and the same error occurs.  Has anyone else run into this?

Here is the basic email template I created:
 
<messaging:emailTemplate subject="test" recipientType="User" relatedToType="Case">
    <messaging:plainTextEmailBody>
    </messaging:plainTextEmailBody>
    <messaging:htmlEmailBody >
        {!URLFOR($Action.Case.View, '111111111111111')}
    </messaging:htmlEmailBody>
</messaging:emailTemplate>


William TranWilliam Tran
What type of access to do have? 

Just trying changing yourself to system admin (or at least permission to create cases) and try again.

It seems buggy, but once you get to work, then it'll continue to work.

Thx.
Prabhat Kumar12Prabhat Kumar12
{!URLFOR($Action.Case.View, '111111111111111')} is generating Link and it should be wrap around <Apex:OutputLink>

Use something like this. It will work for you.
 
<messaging:emailTemplate subject="test" recipientType="User" relatedToType="Case">
    <messaging:plainTextEmailBody >
    </messaging:plainTextEmailBody>
    <messaging:htmlEmailBody >
    <apex:outputLink value="{URLFOR($Action.Case.View, '11111111111')}"/>
    <h1> Your email body </h1>

    </messaging:htmlEmailBody>
</messaging:emailTemplate>
Thanks,
Prabhat