You need to sign in to do that
Don't have an account?
pokalakari naga
Unable to show disply the custom List view with the selected fileds as columns
Hi all,
I'm facing the issue with SOQL query in the example which has given in the vfpage deveploer guide. Can anyone help me over here.Below is the controller class which i have used. And the error I'm facing is
SObject row was retrieved via SOQL without querying the requested field: Account.AnnualRevenue
Thanks in advance.
Regards,
naga.
I'm facing the issue with SOQL query in the example which has given in the vfpage deveploer guide. Can anyone help me over here.Below is the controller class which i have used. And the error I'm facing is
SObject row was retrieved via SOQL without querying the requested field: Account.AnnualRevenue
public class DynamicCustomizableListHandler { // Resources we need to hold on to across requests private ApexPages.StandardSetController controller; private PageReference savePage; // This is the state for the list "app" private Set<String> unSelectedNames = new Set<String>(); private Set<String> selectedNames = new Set<String>(); private Set<String> inaccessibleNames = new Set<String>(); public DynamicCustomizableListHandler(ApexPages.StandardSetController controller) { this.controller = controller; loadFieldsWithVisibility(); } // Initial load of the fields lists private void loadFieldsWithVisibility() { Map<String, Schema.SobjectField> fields = Schema.SobjectType.Account.fields.getMap(); for (String s : fields.keySet()) { if (s != 'Name') { // name is always displayed unSelectedNames.add(s); } if (!fields.get(s).getDescribe().isAccessible()) { inaccessibleNames.add(s); } } } // The fields to show in the list // This is what we generate the dynamic references from public List<String> getDisplayFields() { List<String> displayFields = new List<String>(selectedNames); displayFields.sort(); return displayFields; } // Nav: go to customize screen public PageReference customize() { savePage = ApexPages.currentPage(); return Page.CustomizeDynamicList; } // Nav: return to list view public PageReference show() { // This forces a re-query with the new fields list controller.reset(); controller.addFields(getDisplayFields()); return savePage; } // Create the select options for the two select lists on the page public List<SelectOption> getSelectedOptions() { return selectOptionsFromSet(selectedNames); } public List<SelectOption> getUnSelectedOptions() { return selectOptionsFromSet(unSelectedNames); } private List<SelectOption> selectOptionsFromSet(Set<String> opts) { List<String> optionsList = new List<String>(opts); optionsList.sort(); List<SelectOption> options = new List<SelectOption>(); for (String s : optionsList) { options.add(new SelectOption(s, decorateName(s), inaccessibleNames.contains(s))); } return options; } private String decorateName(String s) { return inaccessibleNames.contains(s) ? '*' + s : s; } // These properties receive the customization form postback data // Each time the [<<] or [>>] button is clicked, these get the contents // of the respective selection lists from the form public transient List<String> selected { get; set; } public transient List<String> unselected { get; set; } // Handle the actual button clicks. Page gets updated via a // rerender on the form public void doAdd() { moveFields(selected, selectedNames, unSelectedNames); } public void doRemove() { moveFields(unselected, unSelectedNames, selectedNames); } private void moveFields(List<String> items, Set<String> moveTo, Set<String> removeFrom) { for (String s: items) { if( ! inaccessibleNames.contains(s)) { moveTo.add(s); removeFrom.remove(s); } } } }
Thanks in advance.
Regards,
naga.
Issue Description
This error "SObject row was retrieved via SOQL without querying the requested field: Account.AnnualRevenue" occurs because the your are trying to use or display the AnnualRevenue field on Account, which is not included in the SELECT clause of your Soql query used to retrieve Account records.
Resolution
Include the AnnualRevenue field, in the list of fields within the SELECT clause of your Soql query and this should fix the issue for you. However, I do not see the line of code from the above snippet where a Soql query is being used which makes me believe that you may have either missed out in including that code piece.
Please DO NOT forget to mark this thread as SOLVED if this answer helps resolve your issue.
Thanks for the quick reply.
I have been trying this by following the below link. Can you please help me where the error is. When i click on the Show these fileds i was getting the error as i mentioned above.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_sample_standard.htm