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
Tin013Tin013 

data not showing in select list

Hi all,

 

I have a select list showing nicely on Apex page. But as soon the the page is exposed as a site, the data in the select list disappears. I wonder whether if it is to do with the permission?

 

I would appreciate massively if someone can help me on this please.

 

The apex code below:

public List<SelectOption> getAccountList() {

        Account[] accounts = [SELECT name FROM Account WHERE Display__c = true];

        List<SelectOption> options = new List<SelectOption>();

        for (Account acc : accounts) {

            options.add(new SelectOption('',acc.Name));

        }

        return options;

 

 

---

On visual force 

<apex:selectlist size="1">

       <apex:selectoptions value="{!accountList}"></apex:selectoptions>

</apex:selectlist> 

 

--

 

Thanks in advance! 

Tin013Tin013

On the public setting area of the page, I have the user license and customer profile as below: 

User LicenseGuest User LicenseCustom ProfileChecked

 

I also had the Create and Edit permission of Account object ticked as well.

 

Am i missing something?

 

Many thanks, 

Tin013Tin013

Hi again,

 

I managed to make the result displayed by changing the class declaration from

public with sharing class MyClass {

 

to

 

public class MyClass { 

 

---

 

Not sure what the difference is and why the select box values need to depend on this.

 

Thanks,