I have been using a visualforce tab to override the default "Recent Order" list view for a custom object "orders__c"
Following is my code…
<apex:page >
<script type="text/javascript">
parent.frames.location.replace("/a0q?fcf=00BK0000000yabc");
</script>
</apex:page>
I face problem everytime I migrate because of hardcoding the list-view id.
Is there a better or out of the box solution? Thanks in advance.
EDIT: I also came across this great hack by deepak. But then again the hardcoding issue arises.
Best Answer
I don't entirely agree with implementing JS as the solution, but independent of that, you can use a Hierarchy Custom Setting (documentation) and merge in a value from it:
EDIT
You could also get the
Id
more programmatically by usingApexPages.StandardSetController
. Take a look at thegetListViewOptions
method, it gives you back aList<SelectOption>
. Each represents aList View
withvalue=Id
andlabel=Name
.Service
The below is a rudimentary and generic attempt to pair an
sObjectType
with aList View Name
and come up with itsId
and also a correspondingURL
.Controller
Using the above service in a specific controller should be trivial.
VisualForce
This would change your
Javascript
specifically to: