I have objects with lookup relationship "A"(Parent) and "B"(Child). Email need to be sent to User whenever a New record "B" is added on "A" and Email body should include URLs of A & B. Currently I am able to display both URL's but not able to find a way to get the most recent record of "B".
I'd suggest the following:
- Create a text field in
Most_Recent_B_Id__c(length = 18)
- Install the Declarative Lookup Rollup Summary package (free, GitHub - essential tool)
- Create a formula field in
ID18__cwith value =
- Configure DLRS to rollup
Most_Recent_B_Id__cbased on the most recent
B. Details on this in release notes
Then, the parent will always have the ID of the most recent child and you can construct a link to that child either in the email template itself or via a HYPERLINK formula in
All that said, VF templates and custom component controllers offer a lot more flexibility and don't pollute your schema with artifacts just to make an email template easier to build.