You need to sign in to do that
Don't have an account?
Dynamic SOQL
Hi friends,
I've to implement dynamic SOQL in my class. I have a class where I have written so many Remote action methods and in each method I have a SOQL query with different where clause and fetching data on the basis of multiple values for each methods. Since I have so many methods so SOQL queries count is also so many. I have to write a dynamic SOQL query so that I can call same query n every methods on the basis of where clause. Any suggesion or sample code for this requirement?
Thanks in Advance
Rajan
I've to implement dynamic SOQL in my class. I have a class where I have written so many Remote action methods and in each method I have a SOQL query with different where clause and fetching data on the basis of multiple values for each methods. Since I have so many methods so SOQL queries count is also so many. I have to write a dynamic SOQL query so that I can call same query n every methods on the basis of where clause. Any suggesion or sample code for this requirement?
Thanks in Advance
Rajan
All Answers
Hope it will be helpful.
Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.
Thanks
Rahul Kumar
I'm doing the same but not giving any result. My createria is as below
If feedback = Invalid the all Records with invalid data in feedback field should display
If feedback = Active or blank then all records escept Invalid should display.
My code is as below:
***************************
// *****recommendationfields+accountFields+contactFields+rationaleFields+cheatSheet***** is field varriable where I m passing all fields from different 5 objects
if(feedback == 'Invalid'){
string query = recommendationfields+accountFields+contactFields+rationaleFields+cheatSheet+ ' '+ 'FROM Recommendation__c'+' ' +'WHERE Feedback__c =:'+feedback+' '+'order by Opportunity_Score__c DESC';
system.debug('Query:' +query);
List<Recommendation__c> recList = database.query(query);
system.debug('RecData:'+recList);
} Else if(feedback == 'Active'){
string query = recommendationfields+accountFields+contactFields+rationaleFields+cheatSheet+ ' '+ 'FROM Recommendation__c'+' ' +'WHERE Feedback__c =:'+feedback+' '+'order by Opportunity_Score__c DESC';
system.debug('Query:' +query);
List<Recommendation__c> recList = database.query(query);
system.debug('RecData:'+recList);
}