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
Marty LavenderMarty Lavender 

How do I include the Case ThreadID in a VisualForce template?

I am creating a visualforce email template that needs to include the case thread id in it so end users are able to reply. 

I am reading that I should be using {!Case.Thread_Id} but when I use this, I get the following error: Unknown property 'core.email.template.EmailTemplateComponentController.Case' 

If I change this to {!relatedTo.Thread_Id} then I get Invalid field Thread_Id for SObject Case


Can someone please help me on this?    I would assume if I was using default templates that SalesForce could actually just input the ThreadID for me as it is an option on the Case > Settings options page but since were using custom VF templates, this wont work.
Best Answer chosen by Marty Lavender
Suresh RaghuramSuresh Raghuram
there will be relatedTo attribute in the first tag (I didnt remember the name to the tag but it will the begining tag) in that put like this

relatedTo="Case"

for getting thread.
{!relatedTo.ThreadId}

If you get the Invalid field Thread_Id for SObject Case.
Create a formula field and capture the Thread Id into it. If formula doesnt work opt for the Trigger to populate the field of Thread Id on Case.

If this solves your issue make this as a solution

All Answers

Marty LavenderMarty Lavender
When I use {!relatedTo.ThreadId} I get the same error: Invalid field Thread_Id for SObject Case
Suresh RaghuramSuresh Raghuram
there will be relatedTo attribute in the first tag (I didnt remember the name to the tag but it will the begining tag) in that put like this

relatedTo="Case"

for getting thread.
{!relatedTo.ThreadId}

If you get the Invalid field Thread_Id for SObject Case.
Create a formula field and capture the Thread Id into it. If formula doesnt work opt for the Trigger to populate the field of Thread Id on Case.

If this solves your issue make this as a solution
This was selected as the best answer
Marty LavenderMarty Lavender
Creating a formula field using this formula: "ref:_00D"&MID(Id,4,1)&RIGHT($Organization.Id, 4) &"._"& LEFT(Id,4)&RIGHT(Id,5) &":ref" and then referencing that with relatedTo in my VF template worked!

Thanks!!!
fgwarb_devfgwarb_dev
This formula isn't always correct.... the thread id format in one of my orgs just changed so caveat emptor.
Hannes MüllerHannes Müller
There is an idea for this requirement: https://success.salesforce.com/ideaView?id=0873A000000LjktQAC