Going through the attribute list for apex:inputField
, I don't see anything that looks like it'll help.
Here's what I suggest: (if using Chrome) right-click and select Inspect Element over the User-type picklist, and see if there's a specific class attached to that element. Then using jQuery, in your .ready
function, hide all elements of that class. Hopefully, the class name for user-type picklists is unique, so it won't bother any other part of the page.
Example: If the class name for user-type picklists = "userType
", have the following jQuery
<apex:includeScript value="{!URLFOR($Resource.jQuery)}"/>
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$('.userType').hide();
});
</script>
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:
parent.frames.location.replace("{!$Setup.Order_Settings__c.Recently_Viewed__c}");
EDIT
You could also get the Id
more programmatically by using ApexPages.StandardSetController
. Take a look at the getListViewOptions
method, it gives you back a List<SelectOption>
. Each represents a List View
with value=Id
and label=Name
.
Service
The below is a rudimentary and generic attempt to pair an sObjectType
with a List View Name
and come up with its Id
and also a corresponding URL
.
public with sharing class ListViewServices
{
public static String getId(SObjectType sObjectType, String name)
{
List<SObject> records = new List<SObject> { sObjectType.newSObject(); }
ApexPages.StandardSetController controller =
new ApexPages.StandardSetController(records);
for (SelectOption listView : controller.getListViewOptions())
{
if (listView.getLabel() == name) return listView.getValue();
}
return '';
}
public static String getUrl(String sObjectType, String name)
{
if (String.isBlank(sObjectType) || String.isBlank(name)) return null;
SObjectType schemaType = Schema.getGlobalDescribe().get(sObjectType);
this.relativeBaseUrl = String.format('/{0}?fcf={1}', new List<String> {
schemaType.getDescribe().getKeyPrefix(),
getId(schemaType, name)
});
}
}
Controller
Using the above service in a specific controller should be trivial.
public with sharing class ListViewController
{
public static final String TYPE_PARAM = 'sobjecttype';
public static final String NAME_PARAM = 'name';
public String listViewUrl { get; private set; }
public ListViewController()
{
this.listViewUrl = ListViewServices.getUrl(
ApexPages.currentPage().getParameters().get(TYPE_PARAM),
ApexPages.currentPage().getParameters().get(NAME_PARAM)
);
}
}
VisualForce
This would change your Javascript
specifically to:
var listViewUrl = "{!URLENCODE(listViewUrl)}";
if (listViewUrl) parent.frames.location.replace(listViewUrl);
Best Answer
At the moment there is no way to restrict button visibility on listviews other than what you already mentioned.
There is an idea for this marked as in development and should be released in Winter 21 https://success.salesforce.com/ideaView?id=08730000000Br37AAC