You need to sign in to do that
Don't have an account?
divyanshu
how to get fields using apex
Hi Everyone,
how to get all the objects with their fields using apex page and class.
like,if i select lead from the dropdown menu then its shows all the lead fields and if i select oppurtunity then its show all the oppurtunity fields.
Please help me on this
as i am new to the salesforce
Thanxs in advance
Regards
Divyanshu
For this you need to write code.. for this you need to learn apex code classes and vf pages
HI,
below is my page and class code.As i am able to retrieve all the object from my organization but not able to find the fields while selecting the anyone of them.
Page code:
<apex:page controller="objectList" showHeader="false" sidebar="false">
<apex:form >
<apex:SelectList value="{!val}" size="1">
<apex:selectOptions value="{!Name}"></apex:selectOptions>
</apex:SelectList>
</apex:form>
</apex:page>
CLASS code:
public class objectList{
public String val {get;set;}
public List<SelectOption> getName()
{
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
List<SelectOption> options = new List<SelectOption>();
for(Schema.SObjectType f : gd)
{
options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
}
return options;
}
}
Any help will be apreciated
Hello friend
For displaying list of fields of selected object use follwoing code
Hope this helps
Regards
Raumil Setalwad
HI
Thanxs for your reply.
I know these are the stupid question but i am not able to clearly myself.
Select Fields means.and what to pass in field name.
Will u tell me is my code is correct ar not??
Thanxs alot.
Please do reply as i wanted to clearify my concepts.
Hello Friend,
I have already mentioned in my previous post when the page is loaded value 'Select Field' will be load as default. as soon as you select object list of its will be displayed in next picklist. Also to mention that according to my functionality i had to use it you can ignore it.
Also the code which is mentioned by you is corect according to my knowledge of describe calls it should populate llist of objects