You need to sign in to do that
Don't have an account?
AHAMMED
In Vf Page
HI
create one inputtext field and one submit button in that time i am entering any sobject in inputtext field and clicking submit button then i want to display enter sobject related data........
create one inputtext field and one submit button in that time i am entering any sobject in inputtext field and clicking submit button then i want to display enter sobject related data........
Here you go, i have created basic skeleton of the code
1. Create Apex class name=QuerySobject and copy paste the code.
2. Create VF page and copy paste the code.
3. Select object from dropdown and click on button.
VF Page Code:
Apex Class Code.
Thanks
Pradeep
Mark this answer solved if this resolve your problem.
All Answers
On button click call apex controller method and use dynamic apex.
Use below link to use dynamic apex.
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_describe_objects_understanding.htm.
Just a suggestion ,use picklist to select sObject rather than using an nputTextField.
Thanks
Pradeep
You can find the full code in the blog. But below code is all you need, use this as reference.
//Code to get all the SObjects
private Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public String selectedObject {get; set;}
public List<String> entities{get; set;}
public List<SelectOption> objNames{get;set;}
public List<SelectOption> getObjectNames(){
objNames = new List<SelectOption>();
entities = new List<String>(schemaMap.keySet());
entities.sort();
objNames.add(new SelectOption('None','--Select Object--'));
for(String name :entities)
{
objNames.add(new SelectOption(name,name));
}
return objNames;
}
Public List<Sobject> queryForSelectedObject(){
// Your query logic goes here. Make use of dynamic apex to construct the query based on selected object from the dropdown
}
VF page Code:
<b>Select Object</b><apex:selectList value="{!selectObject}" multiselect="false" size="1"> <apex:selectOptions value="{!ObjectNames}"/>
Thanks
Pradeep
Mark this answer solved if this resolve your problem.
Here you go, i have created basic skeleton of the code
1. Create Apex class name=QuerySobject and copy paste the code.
2. Create VF page and copy paste the code.
3. Select object from dropdown and click on button.
VF Page Code:
Apex Class Code.
Thanks
Pradeep
Mark this answer solved if this resolve your problem.