You need to sign in to do that
Don't have an account?
Anji Pavuluri
i am trying to fetch the data from Account object with the help of dynamic query i am getting "unexpected token: <EOF> An unexpected error has occurred. Your development organization has been notified."
public class SOQL3_1 {
public List<Account> accounts{set;get;}
public SOQL3_1(){
List<String> listField=new List<String>{'Name','Phone','Rating'};
String queryString='SELECT Id';
for(String s:listField){
queryString=queryString+','+s;
}
queryString=queryString+'from Account';
accounts=Database.query(queryString);
}
}
<apex:page controller="SOQL3_1">
<apex:pageBlock title="Accounts Details">
<apex:pageBlockTable value="{!accounts}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.phone}"/>
<apex:column value="{!a.rating}"/>
<apex:column value="{!a.industry}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
public List<Account> accounts{set;get;}
public SOQL3_1(){
List<String> listField=new List<String>{'Name','Phone','Rating'};
String queryString='SELECT Id';
for(String s:listField){
queryString=queryString+','+s;
}
queryString=queryString+'from Account';
accounts=Database.query(queryString);
}
}
<apex:page controller="SOQL3_1">
<apex:pageBlock title="Accounts Details">
<apex:pageBlockTable value="{!accounts}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.phone}"/>
<apex:column value="{!a.rating}"/>
<apex:column value="{!a.industry}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
There is two changes in Apex Class:
1. Add space before from in : queryString=queryString+' from Account';
2. Add the industry also in listField because you are reffering this field also in Page.
Thanks,
Maharajan.C
Hi Anji Pavuluri,
you can use the below code to check
if you want to show the account in the Aura component you also have to write the Controller or helper js for the aura component and call the class which returns your accounts.
For your Reference, you can take a look at that example
https://developer.salesforce.com/forums/?id=9062I000000Qux3QAC
thanks, Regards
Malika Pathak