function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
UvesUves 

Create a hyperlink using ID

Hi,

 

I wanted to know if i could create hyperlink to a particular record by just having id as information. 

For example, if i did a SOQL query for ids of all accounts:

 

List<id> accids = [SELECT id FROM Accounts];

 

for (id accid :accids)

{

    for each id i need to create a hyperlink and store it as a string. 

    then display it on VF page

}

 

The issue that not all orgs has the same starting URL?

Any suggestion?

 

Thanks

 

 

Best Answer chosen by Uves
InsightTeamInsightTeam

<apex:outputLink value="/{!acc.Id}">acc.Name</apex:outputLink>

All Answers

Jerun JoseJerun Jose
You can just provide the relative URL to your visualforce pages that should be sufficient.

The relative URL will be '/recordID' you can generate that as
String URLString = '/'+recordID;
UvesUves

Based on using a Relative URL, I can show on the VF page the following:

 

Account 1  James Tom (by clicking on James Tom, it would take me to that account)

Account 2  Sarah Base

Account 3  Kist Three

 


etc

 

Thanks

 

 

InsightTeamInsightTeam

<apex:outputLink value="/{!acc.Id}">acc.Name</apex:outputLink>

This was selected as the best answer