0

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".

0

I'd suggest the following:

  • Create a text field in A (parent) called Most_Recent_B_Id__c (length = 18)
  • Install the Declarative Lookup Rollup Summary package (free, GitHub - essential tool)
  • Create a formula field in B (child) called ID18__c with value = CASESAFEID()
  • Configure DLRS to rollup ID18__c into Most_Recent_B_Id__c based on the most recent CreatedDate of 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 A

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.