I have one apex class somehow i need to populate a link. That link should be open records detail page.

This is what i've given in Email Templete. Whenever i send a mail through this Templete i can see a link in email that is opening Record's page. Same like i need it in Apex class.

Please review the FCPA changes for {!Question_Answer__c.Account__c}. {!Question_Answer__c.Link}

enter image description here

This mail is generated by email template. Same like i need it through That class

1 Answer 1


you can do this easily in Apex. create Pagereference method

public pagereference redirectUser()
    return new pagereference('/'+recid);

and call this method and it will redirect to record detail page. You can do something like

String Recordlink = URL.getSalesforceBaseUrl().toExternalForm()+'/'+RecordId;

and this a same link which you are getting in email. You can display it on VF page or pass it to any other method.

  • @chris so from that method you want to redirect to detail page? Jun 29, 2016 at 11:07
  • @chris check my updated answer. Jun 29, 2016 at 11:55
  • @chris this question has accepted answer. Please post a new question and then notify me in comments. Jun 29, 2016 at 13:07
  • Hi Tushar Sharma Please check this URL salesforce.stackexchange.com/questions/129330/…
    – user24737
    Jun 29, 2016 at 13:41

You must log in to answer this question.