Skip to main content

Salesforce ListView as a Home Page component.

Display ListView as a Home Page component.

In this show an example to use the apex:enhancedList VisualForce component in order to display a ListView in a VisualForce Page, and then embed this as a Home Page component. The final result should be something like this:




Step 1: Create a ListView

I suggest doing this with a ListView, as we left the control of which records list will be filtered to Administrators or End users.

First step its to create a list view with the data that you want to show:





Step 2: Create a VisualForce Page 


Go to Setup -> Build --> Develop --> Pages --> New. And create a new Page with this sniped of code:




   
   



The page is using an enhancedList Visualforce Component, for more details about this component here is the documentation:

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=pages_compref_composition.htm|StartTopic=Content%2Fpages_compref_composition.htm|SkinName=webhelp  


The parameter listId should be the 15 digits id of the ListView, to get the ID just copy the last portion of the URL of your ListView:




Then we just need to replace <Value> in the listId="<Value>"  with the id that we got for our ListView.

The final page should look like this:




Step 3: Create HomePage Component.


In this section we just need to create a new component. Go to Setup > Customize > Home > Home Page Components.



Click new, then Create a new Visualforce Area Component.





Next, Select the VisualForce Page recently Created and save the component.



Step 4: Add Component to the proper HomePage Layout




Edit the layout where you want to add the component.




Place the new component where you feel properly and save all.







Step 5: Test your results

Finally, go to your tab and you will see the new ListView. Every-time the list view its edited the component will be adapted. 

Just make sure your users have access to the ListView and are using the proper HomePage Layout.







Step 6: Suggested Improvements.


We could add a simple controller to reference the ListView per Name and not per Id, Therefore when deploying and changing environment we are going to have the right value. 

A good example here: http://blog.jeffdouglas.com/2014/12/12/enhancedlist-visualforce-component/ 















Comments

  1. One question here, I added this to one of my companys orgs and then realized that actions taken within the visualforce component open within the Visualforce box. Is it possible to automatically have actions open in a new tab?

    Thanks!

    ReplyDelete
  2. Hello, I think it won't be possible as we do not control the links in the List View. You would have to do cross browser JavaScript to hack the links is the List view but since Salesforce Protect very well the Cross JavaScript editing I will say the best option you have its to train your users to use the ctrl + click when performing an action.

    Or maybe you can also try wrapping the whole list view:







    Ad ad the target="_blank" to the A link.

    Please let me know how it goes.

    Thanks,

    William

    ReplyDelete
  3. Use this as line 2 in the VF markup base target="_top" as the solution to open links in a new window.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to ByPass and Apex Triggers and Avoid Loops

How to ByPass and Apex Triggers and Avoid Loops Sometimes, when developing a trigger from some reasons we need to by pass the a trigger, may, as I mentioned in my previous post " System.LimitException: Too many SOQL queries: 101 ", sometimes we have loops in our triggers logic.  In Other occasions we just want to bypass because records were processed previously. Our first approach for bypassing its to execute an SOQL query to see if record need to be processed or use fields in the object. trigger TriggerTest on User (before insert. before update) { //First go to Database Set ids = Trigger.newMap.keySet(); List relatedObjs = [SELECT Id,Name FROM relatedObject__c WHERE parent__c in :ids]; //Here check which users need to be processed. List UsersToProcess = new List (); for(User usr: Trigger.new){ //Use the values on relatedObjs to validate UsersToProcess.add(usr); } //Process the records if(UsersToProcess.size() > 0){

Dynamic Section on a VisualForce Page

This will be an small example to show how to create dynamic content inside a Visual Force Page, particularly in a table. Additionally the idea that I wan to introduce here its the use of a Wrapper Class , This class will help us to control the User Interface behavior without having the need to have a new field (Persistent data) back into the database. This we we can "Wrap" the database information into another object, use it in the Interface and them just save back the important information. Something important to consider when using a wrapper class, its there is not automatic field type binding in the VisualForce page to not persistent objects, therefore we need to use fields like "<apex:inputText  /> " Instead of  <apex:inputField /> and validate the format of the data that we collect from the view. The requirements: Have a table that show basic account information. When the checkbook "Configure SLA" its selected allow user to chang