Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi
how to get all fields from account using query? else is ther another way.
thanks
Hi,
Try the below code snippet as reference:
----------- vf page-----------
<apex:repeat value="{!acc}" var="a">
{!a.name} <!-- You can add whatever field you needed -->
{!a.phone}
{!a.fax}
</apex:repeat>
</apex:page>
--------------- apex-------- controller------------------------
public class testimg_cls
{
public string query{get;set;}
public Account acc{get;set;}
public testimg_cls()
Map<string,Schema.SObjectField> mpConField=Account.getSObjectType().getDescribe().fields.getMap();
Set<string> originalvalues = new Set<String>();
originalvalues = mpConField.keySet();
query='select ';
for(string f : originalvalues)
Schema.DescribeFieldResult fldResult=mpConField.get(f).getDescribe();
if(query=='select ')
query=query+string.valueof(fldResult.getName());
}
else
query=query+','+string.valueof(fldResult.getName());
query=query+' from Account limit 1';
acc=Database.query(query);
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
happy great job.
thanks.
Hi,
Try the below code snippet as reference:
----------- vf page-----------
<apex:repeat value="{!acc}" var="a">
{!a.name} <!-- You can add whatever field you needed -->
{!a.phone}
{!a.fax}
</apex:repeat>
</apex:page>
--------------- apex-------- controller------------------------
public class testimg_cls
{
public string query{get;set;}
public Account acc{get;set;}
public testimg_cls()
{
Map<string,Schema.SObjectField> mpConField=Account.getSObjectType().getDescribe().fields.getMap();
Set<string> originalvalues = new Set<String>();
originalvalues = mpConField.keySet();
query='select ';
for(string f : originalvalues)
{
Schema.DescribeFieldResult fldResult=mpConField.get(f).getDescribe();
if(query=='select ')
{
query=query+string.valueof(fldResult.getName());
}
else
{
query=query+','+string.valueof(fldResult.getName());
}
}
query=query+' from Account limit 1';
acc=Database.query(query);
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
Try the below code snippet as reference:
----------- vf page-----------
<apex:repeat value="{!acc}" var="a">
{!a.name} <!-- You can add whatever field you needed -->
{!a.phone}
{!a.fax}
</apex:repeat>
</apex:page>
--------------- apex-------- controller------------------------
public class testimg_cls
{
public string query{get;set;}
public Account acc{get;set;}
public testimg_cls()
{
Map<string,Schema.SObjectField> mpConField=Account.getSObjectType().getDescribe().fields.getMap();
Set<string> originalvalues = new Set<String>();
originalvalues = mpConField.keySet();
query='select ';
for(string f : originalvalues)
{
Schema.DescribeFieldResult fldResult=mpConField.get(f).getDescribe();
if(query=='select ')
{
query=query+string.valueof(fldResult.getName());
}
else
{
query=query+','+string.valueof(fldResult.getName());
}
}
query=query+' from Account limit 1';
acc=Database.query(query);
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
happy great job.
thanks.