You need to sign in to do that
Don't have an account?
ANKITA
Reg: Dynamic Apex Requirement
Hi,
I have a dropdownlist and a button called "display"
Initially i displayed all the objects in my org into dropdownlist.
Select any object then click on "display" button.
Now i would like to display all fields (<apex:inputfield value="{!Account.name}"/>) including lable and componenet type in page block table.
I know how to get all the object into drop down list.
Then i need to perform the save operation.
But after that i am confusing to approach further.
Any suggestions moves me to achieve this.
Thanks,
ANKITA
You must Have prapared a picklist of Objects , where you select object,
You must have bind its selected value to some controller property
On change of it you should pass the selected value which is object API Name.
Could you please share your code contrller and VFP how have you created picklist of Objects.
All Answers
I think you need Field map from Object that you selected , try this it should help you
r1.fields.getMap(); this will give you fields
Hi Shashi
Thanku so much for your reply.
Here in above logic, i need to place my selected object dynamically at 'xxxxxxx'.
Please reply Shashi
Thanks,
ANKITA
Yes you need to put API anme of your selected object
like Account,Contact,
or for custom object it would be like MyCustomObject__c
In the above, you placed object name by static.
But i need to place the selected object dynamically in this place (instead of 'Account') . So that i can access the field apis.
I don't know how to put my selected object dynamically instead of 'Account'.
Thanks,
ANKIT
You must Have prapared a picklist of Objects , where you select object,
You must have bind its selected value to some controller property
On change of it you should pass the selected value which is object API Name.
Could you please share your code contrller and VFP how have you created picklist of Objects.
Used to get the list of Objects from your Organization
----------------------------------------------------------------------------------
<apex:page controller="CustomObjCon">
<apex:form >
CustomObjectNames:
<apex:selectList value="{!pickname}" multiselect="false" size="1">
<apex:selectOptions value="{!names}">
</apex:selectOptions>
</apex:selectList>
</apex:form>
</apex:page>
public class CustomObjCon
{
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
public List<SelectOption> getNames()
{
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
List<SelectOption> options = new List<SelectOption>();
for(Schema.SObjectType f : gd)
{
if(f.getDescribe().getName().contains('__c')) // for custom objects only
options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
}
return options;
}
public String pickname { get; set; }
}
Thanks,
ANKITA