0

I'm trying to create a single visualforce page which will display all record names with their images. So let's say I have CustomObject__c and I want to display all the record names associated with the object. The records also contain an image field. So I want to make a visualforce page that will display all the name and image fields of all the records associated w/ CustomObject__c.

In addition, I would like each name to be clickable, if possible, (or each name to have a button which would serve the same function) and when a record name is clicked, the user will be redirected to another visualforce page which displays all the details/fields of that specific record.

hopefully my wording isn't too convoluted...

2
  • 1
    If you have a wish to receive a good answer then share your code – Santanu Boral Jun 25 '17 at 1:27
  • You could use a custom controller class to fetch all the records with respect to the object you wanted. In the VF page, use <apex: repeat> and display the fields. Use <apex:outputLink> inside the repeat tag to make each record name field clickable. – Arnold Jr. Jun 25 '17 at 1:28
1

If I understand correctly, you want a kind of "alternate list view". In that case, take into consideration other solutions. What you are proposing, in my understanding, is simply a list view that when you click on a record it takes you to the record. That's pure Salesforce standard. An alternate solution would be to simply create a new List view with a formula field referencing the image, as Adam proposed.

Where you to eventually develop the Visualforce, use pagination. On the contrary, the solution would be highly unscalable as the records grow: loading times would grow unlimitedly. Apart from that, just create a custom controller that brings all the records (less than 50.000, because otherwise you would reach a Governor Limit with SOQL) in the constructor and paint them in your Visualforce with <apex:repeat>.

0

I believe you can solve your problem with just a declarative solution and no Visualforce. Lets say you have ParentObject__c with a related list of ChildObject__c. In the ChildObject__c, you add a formula field that outputs text which you can then use IMAGE().

IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6El", "Image Description Here")

Or

IMAGE("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
"Google Logo")

Add your new image formula field to the related list in ParentObject__c and you are all set.

Some other examples here for the formula field.

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