I have a Visualforce Email Template which is as follows
<messaging:emailTemplate recipientType="Contact"
relatedToType="Case"
subject="Test">
...
<apex:repeat first="0" rows="1" value={!ralatedTo.workorders} var="worder">
Click <a href = "{!$Lable.myURL}?workorderId={!worder.Id}">here.</a>
</apex:repeat>
...
</messaging:emailTemplate>
Using the <apex:repeat>
I am getting one Workorder record data which I need to pass in the URL. I need the Workorder here which is last created (1st result when Workorder query is done with order by creation date in desc). Is there a way I can get it without controller class?
Also, I tried the solutions with the controller class. I am creating a controller class and an apex component but how can I pass the data from apex component to the email template as I don't want to display it but reuse the value?