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
NeilJWNeilJW 

List Default Value

Hi all, I'd be super thankful if any of you can point me in the right direction. I'm new to this so here goes. I'm creating a tab to replace the opportunity tab (actually 2 tabs). Each tab will skip the record type selection screen and I want each tab to default to a particular list view but still allow the list view to be changed if necessary. So far I have this that does everything I want it to except default to a particular list view. How can I get it to default to a particular list view rather than selecting the last list view that the user selected when they were last on the page?

<apex:page standardController="Opportunity" recordSetVar="opportunities" tabstyle="Test__tab" sidebar="false">


  <apex:pageBlock title="Account Opportunities">
  

  <apex:form id="theForm">

  <apex:commandbutton action="{!URLFOR($Action.Opportunity.New, $ObjectType.Opportunity, [p3='012A0000000xcAf', save=1])}" title="New Account Opportunity" value="New Account Opportunity"> </apex:commandbutton>    


    <apex:panelGrid columns="2">
      <apex:outputLabel value="View:"/>
      <apex:selectList value="{!filterId}" size="1">
        <apex:actionSupport event="onchange" rerender="list"/> 
        <apex:selectOptions value="{!listviewoptions}"/>
      </apex:selectList>
    </apex:panelGrid>
  



  

  </apex:form> 
  

    <apex:pageBlockSection >
        <apex:pageBlockTable value="{!opportunities}" var="o" id="list"> 
      <apex:column value="{!o.name}"/>
    </apex:pageBlockTable>
    </apex:pageBlockSection>
    
    </apex:pageBlock>
</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
NeilJWNeilJW

Oops! It didn't work after all (I just happened to be defaulting to the right page on accident while testing). I did eventually get it to work using this syntax:

/apex/visualforcepagename?fcf=[listviewid]

 

For example:


/apex/VFTestTwo?fcf=00B80000007mchd

 

 

So in summary what I did was create the visualforce page. Then refer to the visualforce page using a Web tab where I was able to type in the necessary URL. In the URL field I put the above string.

 

Thanks!

All Answers

bob_buzzardbob_buzzard

The list view is specified by the controller 'filterId' property, which defaults to the last list view if not specified.

 

You can specify this in the page URL,  e.g.

 

https://kab-tutorial.na6.visual.force.com/apex/RecordSet?filterId=00B80000007mchd

 

NeilJWNeilJW

Thank you for the quick reply. Unfortunately I don't really know how to do what you are suggesting!

 

So far what I have done is create a visualforce page which contains the above code. Then I created a custom visualforce tab to reference that visualforce page. I don't see anywhere that I can specify a URL for that tab or any parameters. I did try creating a second tab that was a Web tab that had a URL and I was able to reference the first tab I created but not the visualforce page directly. On that URL that referenced the first tab I was able to put a parameter on it like you suggest. While this worked it seems kind of an awkward way of doing things and it displays the entire page within the second tab so that I then have two sets of headers (I could probably figure out how to turn off the header as I think I've seen that in the documentation but that seems rather an awkward way to do it).

Am I missing something really simple?

Thanks,

Neil

bob_buzzardbob_buzzard

There's probably a few ways to do this.  If you can create a custom controller, you can apply the filter criteria in the constructor.  An iframe in the visualforce page may also be an option, or a new visualforce page with a page level action that redirects to your visualforce page with the URL set as appropriate.

 

If it were me, I'd go for the last option.  There's an example of page level override in the following cookbook recipe that hopefully gives some pointers at:

 

http://developer.force.com/cookbook/recipe/overriding-a-page-for-some-but-not-all-users

 

 

NeilJWNeilJW

Thank you! I got it to work. I am able to directly reference a VisualForce page from a Web tab without creating an intermediary tab.

 

All I had to do was change URL reference to /apex/visualforcepagename?RecordSet?filterId=[id]

 

example:

/apex/VFTestTwo?Rec​ordSet?filterId=00B80000007mchd

 

Thank you!

bob_buzzardbob_buzzard

Cool.  Glad to hear you got there.

NeilJWNeilJW

Oops! It didn't work after all (I just happened to be defaulting to the right page on accident while testing). I did eventually get it to work using this syntax:

/apex/visualforcepagename?fcf=[listviewid]

 

For example:


/apex/VFTestTwo?fcf=00B80000007mchd

 

 

So in summary what I did was create the visualforce page. Then refer to the visualforce page using a Web tab where I was able to type in the necessary URL. In the URL field I put the above string.

 

Thanks!

This was selected as the best answer