Wednesday, 2 October 2013

Limit fields to update in Mass Update

Limit fields to update in Mass Update

I use these two codes to select a list of field names to be updated. But I
would rather want to limit the fields for update.The code below returns
all available fields. How can I do this?
// this is the controller code
public List<SelectOption> getFieldTypeOptions() {
// prevent url hacking
if (objs.size()<1) return null;
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','-None-'));
Schema.DescribeSObjectResult sObj = discoverSObjectType(objs.get(0));
fieldMap = sObj.fields.getMap();
List<String> keys = sortByFieldLabel(fieldMap);
for(String key:keys) {
Schema.DescribeFieldResult d = fieldMap.get(key).getDescribe();
if(d.isAccessible() && d.isUpdateable()) {
if (isSupportedFieldType(d)) {
String label = d.getLabel();
if(d.isCustom()) label += ' (' + key + ')';
options.add(new SelectOption(key, label));
}
}
}
return options;
// This is the VisualForce Page
<apex:selectList id="pickList" size="1" value="{!fieldName}" required="true">
<apex:selectOptions value="{!fieldTypeOptions}"/>

No comments:

Post a Comment