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
rosems2rosems2 

Standard List Views

Is it possible to create a standard list view in code?  Basic idea is a trigger on Account creation, when Account ABC is created I want a list view created on Contacts with the filter of Account Name equals ABC (Account Name of newly created Account). The list view would have some default columns like FirstName,  LastName, Phone and be visible only to the user that created the new Account.

Hope that makes sense, hoping someone has some ideas. THANKS
Best Answer chosen by rosems2
rosems2rosems2
Thanks for your comments. I found where you can do this through the metadata API. Here is a great post  https://github.com/financialforcedev/apex-mdapi

All Answers

Wizno @ ConfigeroWizno @ Configero
I wouldn't recommend this, you'll end up having way way too many list views to manage. As of today there is no way to create list view through Apex. While you do have access to apex:listViews and apex:enhancedList

https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_listViews.htm
https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_enhancedList.htm

If you absolutely need it though, you'll need to implement a custom VF page. Here's a starting points: https://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_sosc_list_views.htm
rosems2rosems2
Thanks for your comments. I found where you can do this through the metadata API. Here is a great post  https://github.com/financialforcedev/apex-mdapi
This was selected as the best answer