You need to sign in to do that
Don't have an account?
Lucky29
dynamic SOQL query????
Hi,
string namevf=name;
For(Contact objContact:[SELECT :namevf,id,MailingStreet,MailingCity,MailingCountry,MailingState FROM Contact])
{
//some code
}
in the above code , I want to replace ":namevf" with "name"(or any other API name) if I store the API name in another string variable ...
can any one help me on this......
string namevf=name;
For(Contact objContact:[SELECT :namevf,id,MailingStreet,MailingCity,MailingCountry,MailingState FROM Contact])
{
//some code
}
in the above code , I want to replace ":namevf" with "name"(or any other API name) if I store the API name in another string variable ...
can any one help me on this......
Or..
If you need to dynamically pick fields from a SOQL query you have to options:
-
Add all the potential fields you'll be selecting to your SOQL query
-
Use Dynamic SOQL (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_soql.htm)
For the latter you would construct your SOQL in a string like so:All Answers
I hope we cannot change the query dynamically
Or..
If you need to dynamically pick fields from a SOQL query you have to options:
-
Add all the potential fields you'll be selecting to your SOQL query
-
Use Dynamic SOQL (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_soql.htm)
For the latter you would construct your SOQL in a string like so:Thanks for the solution and it's working
Thanks for this.......