You need to sign in to do that
Don't have an account?
Ezmo
Turn SOQL results into links
Hi, I'm not sure if this should be in the Apex or Visualforce section as it spans both.
Anyway, I've created a table of results from an SOQL query and I was wondering if it was possible to make it so that the results become links to the records they are representing.
I've pasted my controller extension and page code below.
Many thanks in advance
Eran
<apex:page standardController="Event_Services_Training__c" extensions="whatsOnExtension" tabstyle="What_s_On__tab"> <apex:pageblock title="What's On?"> <apex:pageblocktable var="a" value="{!training}" columns="6"> <apex:column value="{!a.Title__c}"/> <apex:column value="{!a.Venue__c}"/> <apex:column value="{!a.Start_Date_of_Event__c}"/> <apex:column value="{!a.End_Date_and_Time_of_Event__c}"/> <apex:column value="{!a.Places_Remaining__c}"/> <apex:column value="{!a.Id}"/> </apex:pageblocktable> </apex:pageblock> </apex:page>
public class whatsOnExtension{ public final Event_Services_Training__c training; public whatsOnExtension(ApexPages.StandardController stdController) { this.training = (Event_Services_Training__c)stdController.getRecord(); } public List<Event_Services_Training__c> trainingQuery = [SELECT Id, Name, title__c, Start_Date_of_Event__c, End_Date_and_Time_of_Event__c, venue__c, places_remaining__c FROM Event_Services_Training__c ORDER BY Start_Date_of_Event__c ASC NULLS FIRST]; public List<Event_Services_Training__c> gettraining(){ return trainingQuery; } public void table(){ for(Event_Services_Training__c t : trainingQuery){ Event_Services_Training__c tempTraining = new Event_Services_Training__c(); trainingQuery.add(tempTraining); } } }
With sobjects its usually just a case of outputting a link to the sobject id:
Something like:
All Answers
With sobjects its usually just a case of outputting a link to the sobject id:
Something like:
That worked perfectly. Thank you very much bob_buzzard!
Typical that it was something so simple :smileytongue:
Eran
The beauty of VF and apex - lots of things are simple!