+ Start a Discussion
shweta raghav 13shweta raghav 13 

how to query 130 fields without getting error :query too many fields on workbench while executing rest service

@RestResource(urlMapping='/listRevenueProfile/*')

global with sharing class RESTRevenueprofileController {

@HttpGet
  global static List<Revenue_Profile__c> fetchRevenue()
  {    
     list<Revenue_Profile__c>lst1=new list<Revenue_Profile__c>();
   
   lst1=[Select Aug_17__c,Apr_17__c,January_2020_Sales_Updated__c,January_2021_Sales_Updated__c,July_2016_Sales_updated__c,July_2017_Sales_Updated__c,July_2018_Sales_Updated__c,July_2019_Sales_Updated__c,July_2020_Sales_Updated__c,June_2017_Sales_Updated__c,June_2018_Sales_Updated__c,June_2019_Sales_Updated__c,June_2020_Sales_Updated__c,June_2021_Sales_Updated__c,March_2017_Sales_Updated__c,March_2018_Sales_Updated__c ,
        March_2019_Sales_Updated__c,March_2020_Sales_Updated__c,March_2021_Sales_Updated__c,May_2017_Sales_Updated__c,May_2018_Sales_Updated__c,May_2019_Sales_Updated__c,May_2020_Sales_Updated__c,May_2021_Sales_Updated__c,November_2016_Sales_Updated__c,November_2017_Sales_Updated__c,November_2018__c,November_2019_Sales_Updated__c,November_2020_Sales_Updated__c,October_2016_Sales_Updated__c,October_2017_Sales_Updated__c,
        October_2018_Sales_Updated__c,Jun_19__c,Jun_20__c,Jun_21__c,Mar_17__c,Mar_18__c,Mar_19__c,Mar_20__c,Mar_21__c,May_17__c,May_18__c,May_19__c,May_20__c,May_21__c,Nov_16__c,Nov_17__c,Nov_18__c,Nov_19__c,Nov_20__c,Oct_16__c,Oct_17__c,Oct_18__c,Oct_19__c,Oct_20__c,Sep_16__c,Sep_17__c,Sep_18__c,Sep_19__c,Sep_20__c from Revenue_Profile__c WHERE CreatedDate >=2015-07-01T00:00:00Z];
    System.debug('----lst1----'+lst1);
    
    return lst1;
    
     list<Revenue_Profile__c>lst=new list<Revenue_Profile__c>();
   lst=[Select Opportunity_id__c,X18_Digit_Opportunity_ID__c,April_2017_Sales_Updated__c,April_2018_Sales_Updated__c,April_2019_Sales_Updated__c,April_2020_Sales_Updated__c,April_2021_Sales_Updated__c,August_2016_Sales_Updated__c,August_2017_Sales_Updated__c,August_2018_Sales_Updated__c,August_2019_Sales_Updated__c,August_2020_Sales_Updated__c,
        December_2016_Sales_Updated__c,December_2017_Sales_Updated__c,October_2019_Sales_Updated__c,October_2020_Sales_Updated__c,September_2016_Sales__c,September_2017_Sales_Updated__c,September_2018_Sales_Updated__c,September_2019_Sales_Updated__c,September_2020_Sales_Updated__c,Apr_18__c,Apr_19__c,Apr_20__c,Apr_21__c,Aug_16__c,Aug_18__c,Aug_19__c,Aug_20__c,Dec_16__c,Dec_17__c,Dec_18__c,Dec_19__c,Dec_20__c,Feb_17__c,Feb_18__c,     
        Feb_19__c,Feb_20__c,Feb_21__c,Jan_17__c,Jan_18__c,Jan_19__c,Jan_20__c,Jan_21__c,Jul_16__c,Jul_17__c,Jul_18__c,Jul_19__c,Jul_20__c,Jun_17__c,Jun_18__c,December_2018_Sales_Updated__c,December_2019_Sales_Updated__c,December_2020_Sales_Updated__c,February__c,February_2018_Sales_Updated__c,February_2019_Sales_Updated__c,February_2020_Sales_Updated__c,February_2021_Sales_Updated__c,January_2017_Sales_Updated__c,January_2018_Sales_Updated__c,January_2019_Sales_Updated__c from Revenue_Profile__c WHERE CreatedDate >=2015-07-01T00:00:00Z];
      System.debug('----lst----'+lst);
    return lst;
   
 } 
}
https://help.salesforce.com/articleView?id=000176969&type=1 (not work for me)
 
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Shweta,
  • I'd suggest you take this up with support, as they should be able to advise you more detail exactly what the issue is.

I hope it will be helpful.

BestRegards
RahulKumar
Balayesu ChilakalapudiBalayesu Chilakalapudi
To make a valid query,  
Go to Developer Console > click File> open > Objects > in the filterbox enter Revenue_Profile__c > open  
select the fields to query
​click on query button
copy the query and place it in your code.
Let us know if it helps you.
shweta raghav 13shweta raghav 13
not able to extract the data from above method,my code woks in sandbox not in production it gives error of heap size.(approx data:1464875)
@GM@GM
Hope below blogs are helpfull to reduce apex heap size

https://help.salesforce.com/articleView?id=000004186&type=1
http://blog.jeffdouglas.com/2010/08/16/managing-the-heap-in-salesforce-com/

Reards,
GM