2

I have multiple select lists on my vf page. All work fine, except this one:

<apex:pageBlockSection title="Product" >
    <apex:pageBlockSectionItem rendered="true">
        <apex:outputLabel value="{!$ObjectType.ZInstallation__c.fields.DiscountProfile__c.Label}" rendered="true" />
        <apex:selectList value="{!ZInstallation__c.DiscountProfile__c}" size="1" rendered="true" >
            <apex:selectOptions value="{!DiscountProfileList}" />
        </apex:selectList>
    </apex:pageBlockSectionItem>
</apex:pageBlockSection>

The list should show data from custom object (like other lists too). The controller:

public List<SelectOption> getDiscountProfileList() {
    List<SelectOption> options = new List<Selectoption>();
    List<ZDiscountProfile__c> profileList = [SELECT Id, Name FROM ZDiscountProfile__c ORDER BY Name];

    options.add(new selectOption('', 'none'));

    for (ZDiscountProfile__c profile : profileList) {
        options.add(new selectOption(String.valueOf(profile.Id), profile.Name));
    }

    return options;
}

Discount list is missing, other lists (media) work: Missing Discount

  • Could it be possible that this field is marked as hidden? – Martin Lezer Mar 29 '17 at 15:24
  • ok, I'am a sysadmin user and field was hidden for me, but why?? I created it like all other fields. – Samwise_71 Mar 29 '17 at 15:34
  • I think that the fields created in another environment are marked as hidden when the field is deployed. Could it be possible that this field was deployed from sandbox to production? – Martin Lezer Mar 29 '17 at 15:43
1

When you deploy a field from one environment to another (sandbox to sandbox, sandbox to prod), the permissions (Field-Level Security, or FLS) are not copied over.

In the destination org, the default FLS settings are that nobody (not even sysadmins) are able to read or write the field. You will be able to see the field when you look at the fields on the object through the setup menu, but you won't be able to see it on Visualforce pages.

A similar situation exists if you try to query such a field. I don't remember off the top of my head if you'd get a compile-time error, a run-time error, or if the field will simply be null if you attempt to query such a field.

Fixing this issue is simply a matter of updating the FLS to give (at least your own profile) at least read access to the field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.