Tuesday, 19 November 2013

Record URL in Email Templates - Without Hardcoding Domain Instance and RecordId

Record Link in Email Templates .

For Inserting a Particular Record Link , we hardcode the RecordId preceded by hardcoded Domain Instance(cs16.salesforce.com / na3.salesforce.com) , It should cause problems whenever the Domain changes, or the Template from Sandbox moved to Production.

Here is just some short workaround:

Use below MergeField:
The Same applicable for other objects too.


{!Account.Link}


Thursday, 14 November 2013

ROLLUP Using SOQL With Lookup Relationship

To get the Count of Child Records for the Particular Parent Record for the two different objects with (Master-Detail Relationship) - just the Standard Rollup Feature is Enough.

What if, we needs to achieve it for a Lookup-Relationship.
Definitely one should opt for Complicated Custom Apex Code to achieve it ,but we can do that just by using some simple SOQL function to get the Child count for the Particular Parent Record.

SOQL Function  :  GROUP BY ROLLUP

Example Code:

Parent : Account
Child : Opportunity

I am going to get the Number of Opportunity Records for the Particular Account Record.

  1. SELECT AccountId, COUNT(Name) NoOfCount FROM Opportunity GROUP BY ROLLUP(AccountId)


Result: