+ Start a Discussion
shankar anandshankar anand 

Filter Id and ViewListOptions

I was going through the following code:


<apex:page standardController="Account" recordSetVar="accounts">
<apex:form>
<apex:selectList value="{!filterid}" size="1">
<apex:selectOptions value="{!listviewoptions}"/>
</apex:selectList>
<apex:commandButton value="Go" action="{!list}"/>
</apex:form>
</apex:page>

Can someone tell me how I can see the Filter IDs for the Custom Views I create on the List View page? Also is there a way to see the ListViewOptions? Are they also IDs or plain Strings?

 
BalajiRanganathanBalajiRanganathan
whenever you view an list view, the addressbar changes to something similar below

https://<x>.salesforce.com/a3N?fcf=00B70000007iWhy
here 00B70000007iWhy is filter id.

listviewoptions is type of List<SelectOption>. which will have value and lable. value is Id as above, and the name is list view name.

The below code generates html <option> for list of listview you have for an object
VF :
<apex:selectOptions value="{!listviewoptions}"/>

HTML:
<option id="00B70000007iWhy">listview1</option>

<option id="00B70000007zWhy">listview2</option>

below code will generate html <select>
VF :<apex:selectList value="{!filterid}" size="1">
Html <select name="filterid">options..</select>

so what ever list view you choose, the id of the list view will be passed to filterid param, the standar controller will use that param to filter the records.
shankar anandshankar anand
Thanks a lot Balaji for replying..I've one issue. I can see a static value in my URL even if I keep changing the List View Options from the List View dropdown. e.g in Accounts list view I filtered via My Accounts, New This Week, New Last Week, etc. But the URL remains same i.e it shows the Filter Id of the view which I used for the first time.

What am I missing here? Isn't it true that Filter Id will be different for each of My Accounts, New This Week, New Last Week, etc??
BalajiRanganathanBalajiRanganathan
it is ok if you are seeing static link. if the request is POST, it will not show it in the URL.
filterid will be different for each list view. just verify your result if you getting correct result when you change the list view option.