You need to sign in to do that
Don't have an account?
ListView in Apex Code or Visualforce Page
Hello,
I have a requirement where I need to display the columns seleted / defined for a particular listview in a custom visualforce page.
I know that there is a property ListView. Columns in Metadata API for Salesforce, but I am not sure on how to use it in APEX Code.
Can anyone please help me with regard to this ?? Any examples on how to use this are appreciated.
Thanks.
Kartik
Hi Karitk,
hi use below code
Hi Hitesh,
I am not sure if you got my question, I am trying to get the LISTVIEW columns into my apex code, so that I can programatically dynamically change the LISTVIEWS from apex code.
Hi Andrew
We want to create a custom account list similar to Salesforce out of the box account list page. We are able to filter the records in our table on the basis of list views(with the help of filter ID). But we would also like to get the columns dynamically from the list views. Is there a way to get the columns from each list views?
Your quick response would really help us in moving forward. Thanks in advance.
Raj
Hi Kartik,
I also need the same thing to dynamically display the columns of the selected view. Did you get your answer from anywhere. If yes, please help me.
Regards,
Aman
Hi Kartik,
I wanna ask you, did you find any solution for this post ? I also need to get listviews in apex to display fully customized VF page.
I just wonder is it possible or not ?
Thanks.
Hi Karthik,
Did you solve this issue. I am also looking for the same thing. I am able to display one object list view with corresponding records in visual force page. But i want to display account,contact,lead list views in the same picklist. If your issue solved please help me.
This is my code
<apex:page standardController="Account" recordSetvar="accounts">
<apex:pageBlock title="Viewing Accounts">
<apex:form id="theForm">
<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:pageBlockSection >
<apex:dataList var="a" value="{!accounts}" id="list">
{!a.name} </apex:dataList>
</apex:pageBlockSection>
</apex:form>
</apex:pageBlock>
<!-- <apex:pageBlock title="Viewing Contacts">
<apex:form id="theForm">
<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:pageBlockSection >
<apex:dataList var="a" value="{!account.contacts}" id="list">
{!a.name} </apex:dataList>
</apex:pageBlockSection>
</apex:form>
</apex:pageBlock>
<apex:ListViews type="Contact" />-->
</apex:page>
Thanks,
Lakshmi.
You either need to use the Metadata API wsdl in your APEX Code. Please see below link
Metadata API
OR
Use the fieldsets and retrieve the fieldsets using APEX for multiple objects.
Read this link to display account list view in lightning and insert account.
https://sfdcadda.blogspot.in/2017/05/insert-account-and-show-list-view-of.html