You need to sign in to do that
Don't have an account?
kavya.ax1320
Required Fields of object into Select List.
Hi !!!
Is there a possibility to get all the required fields of an object into select List.?
Example
All the Required Fields of the Account to be listed into a select list.
Thanks in Advance.
Manju
Hi kavya ,
Better to follow this link
http://boards.developerforce.com/t5/Apex-Code-Development/Detect-a-required-field-in-Apex/td-p/129693
All Answers
Hi follow This code it may be help ful to you
<apex:page controller="exampletest">
<apex:form >
<apex:pageBlock >
<apex:repeat value="{!acc}" var="a">
{!a.name} <!-- You can put whatever required fields-->
{!a.phone}
{!a.fax}
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
public class exampletest {
public string query{get;set;}
public Account acc{get;set;}
public exampletest ()
{
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);
}
}
Hi Premanath,
Thanks for the reply, but as per my understanding to the above code. It would return all the fields of the Account object.
I need only the required fields of the account object.
Thanks.
Hi kavya ,
Better to follow this link
http://boards.developerforce.com/t5/Apex-Code-Development/Detect-a-required-field-in-Apex/td-p/129693
Hi Premanath,
Thanks, That worked..
Super!!!