You need to sign in to do that
Don't have an account?
nishad basha 7
How to display the standard object records once click search command button in visualforce page
if i select any standard object click on search button i want to display the related object records
use this bunch of code it will help you.
All Answers
Here are the steps for it.
1. Generate standars object and their corresponding fields in list of options dynamically in your controller.
2. Upon selection of object name and ,call your controller method to frame dynamic query.(Take care for each object's fields)
3. Execute query and display result.
Let us know if it helps you.
Use this bunch of code it will help you.
How to display the standard object records without use these tag <apex:selectoptions> once click search button display the records using <apex:inputtext> tag. please give some examples of that code.
Keyur has mentioned that in above example.
Hi nishad basha 7
What you want to do ? Please paste your requirement .
<apex:selectList value="{!selectedSobject}" multiselect="false" size="1" >
<apex:selectOption itemValue="Account" itemLabel="Accounts"/>
<apex:selectOption itemValue="Contact" itemLabel="Contacts"/>
<apex:selectOption itemValue="Opportunity" itemLabel="Opportunity"/>
</apex:selectList>
Don't Use This tag
U can Use
<apex:inputText value="{!searchKeyword}" action = {!serch}/> when press the button then display the records
Sure we can use inputSelect in above case ,but you have to enter object name correctly everytime.
so better to use picklist.
Hope this helps.
use this bunch of code it will help you.
i want to diaplys how meany records are founded in the same requerment
thank u so much
Use this bunch of code:
If this code will help then like this comment and select Answer as best answear in below link so everyone can get the answer easily.
https://developer.salesforce.com/forums?id=906F0000000BCFpIAO. This link is posted by you so in that also i posted the same answer so don't forget to select that asnwer as best answer.
How to run the user require fields for Test class in salesforce. i want to show percentage code coverage. please give some ideas with example code.
Hi Nishad basha 7,
You can use this link https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods where you can learn how to write test class , with basic example , i hope that will help you
Thanks,
Hi, Keyur Modi
How to run the userdetails with all require fields in test class.But i want to show the code coverage of percentage that Apex class. how that one can give me one example for that.
Hi nishad basha 7,
write the test class with help of this link https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods nad save the class after saving the class there is one button called Run Test if you click on that it will run the test class and after that it will show the code coverage to original class.
Still if you found dificulty then feel free to ask.
<apex:page controller="Quetion1Controller">
<apex:form >
<apex:inputText value="{!selectedSobject}" />
<apex:commandButton value="Search" action="{!doSearch}"/>
</apex:form> Total Records : {!Total} <apex:pageBlock >
<apex:pageblockTable value="{!lstQuery}" var="eachRecord">
<apex:column value="{!eachRecord.id}"/> <apex:column value="{!eachRecord['Name']}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:page>
Controller public class Quetion1Controller {
public string selectedSobject{get;set;}
public List<Sobject> lstQuery{get;set;}
public integer Total{get;set;}
public Quetion1Controller(){
lstQuery=new List<Sobject>();
}
public Void doSearch(){
string Query=''; Query='SELECT id,Name FROM '+ selectedSobject; system.debug('==Query=='+Query);
lstQuery=Database.query(Query);
Total=lstQuery.size();
system.debug('==lstQuery=='+lstQuery);
}
}
In This Code I want tothrow the custome error and ine more thing here i want to dispaly case records also...... plz solve the problem
Hi SS,
FOr the custom error you can use <apex:pageMessage> tag and for the case object record you need to change the string Query.Because Name Filed is not there in case.
string Query=''; Query='SELECT id,CaseNumber FROM '+ selectedSobject; system.debug('==Query=='+Query);
still if you found any dificulty then feel free to ask.
wehn i am serching any object in the serch it show's the object lerated records
for ex:- now i am serching account object it show's account records
now i am serching case object it throw error
Hi ,Keyur Modi
how to display the once click search button custom error message will show in same page
Hi SS,
in clontroller you can check like
if(selectedSobject=='Case'){
Query='SELECT id,CaseNumber FROM '+ selectedSobject; system.debug('==Query=='+Query);
}
else{
Query='SELECT id,Name FROM '+ selectedSobject; system.debug('==Query=='+Query);
}
still if you found dificulty feel free to ask.
Can you give me the clear idea about what exactly you are asking for. With your above quetion i am not able to understand your quetion
if(selectedSobject=='Case'){
Query='SELECT id,CaseNumber FROM '+ selectedSobject; system.debug('==Query=='+Query);
}
else{
Query='SELECT id,Name FROM '+ selectedSobject; system.debug('==Query=='+Query);
}
ur giving the code is not working
f(selectedSobject=='Case'){
Query='SELECT id,CaseNumber FROM '+ selectedSobject; system.debug('==Query=='+Query);
}
else{
Query='SELECT id,Name FROM '+ selectedSobject; system.debug('==Query=='+Query);
}
This is Not working I Traied It ......
use this code this code it will help you in your requirement. still you found any dificulty then feel free to ask.
I think you want to display custom error in visual force page. please reffer above comment , try that above code it will help you in your requirment ,in that code there is custom error displayed . if you try that code then in that code if you enter wong object name then it will display error message.
still you have any doubt then feel free to ask.
Thank U soo Much
when iam searching case that time show data correct but after i am enter another object that time show the error
Here Showing Correct
when i am entering object name wrong that time throwing system error
I Dont Want Show This error Here
Due to this issue you only Ashish_Sharma_DEVSFDC suggest you to use picklist.
how to display Account object labels using visualforce page? how to solve the solution please give any ideas.
Hi, Keyur Modi
my requirement u must have one require field,when i click the save (don't fill the values) it will show custom error message
page:
<apex:page controller="Stall1" tabStyle="Stall__c" sidebar="false">
<apex:form >
<apex:pageBlock mode="edit" title="enter stall detail">
<apex:pageBlockButtons location="bottom">
<apex:pageMessages ></apex:pageMessages>
<apex:commandButton action="{!Save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Book__c}" required="true"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
class:
public with sharing class Stall1 {
public String getStall() {
return null;
}
Public Stall__c stall;
public pageReference save(){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));
return null;
}
}
here iam getting the these type of error: Could not resolve the entity from <apex:inputField> value binding '{!Book__c}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable
How to solve the above scenario please give some ideas.
How to retrieve the table format Account of contacts using visualforce page?
i want to display the number of Accounts having contact records. how to solve above scenario please give some ideas.