You need to sign in to do that
Don't have an account?

create a visual force page to fetch all records ids in the org
Hi all,
My requirment is to create a visual force page (apex class) in that an id field and search button should be inserted........
when i paste an record id in the id field of visualforce page record should be displayed and related lists should be also displayed
My requirment is to create a visual force page (apex class) in that an id field and search button should be inserted........
when i paste an record id in the id field of visualforce page record should be displayed and related lists should be also displayed
Hi Nihar,
There are two ways to approach this problem. I will share the simpler one with you, because the other one is too complex to explain for me.
You can start by making a visual force page with a custom controller. Your VF page will include two main things:
1. An input type field where you will enter the ID to search.
2. A button to call search function.
And your custom controller code will look something like this:
Let me know if it helps.
Thanks!
All Answers
Hi Nihar,
There are two ways to approach this problem. I will share the simpler one with you, because the other one is too complex to explain for me.
You can start by making a visual force page with a custom controller. Your VF page will include two main things:
1. An input type field where you will enter the ID to search.
2. A button to call search function.
And your custom controller code will look something like this:
Let me know if it helps.
Thanks!
public list <account> acc {get;set;}
public string searchstring {get;set;}
public pagecontroller( ) {
}
public void search(){
string searchquery='select name,id from account where name like \'%'+searchstring+'%\' Limit 20';
acc= Database.query(searchquery);
}
public void clear(){
acc.clear();
}
}
<apex:page Controller="pagecontroller" >
<apex:form >
<apex:inputText value="{!searchstring}" label="Input"/>
<apex:commandButton value="Search" action="{!search}"/>
<apex:commandButton value="Clear" action="{!clear}"/>
<apex:pageBlock title="Search Result">
<apex:pageblockTable value="{!acc}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
thankyou for the code ..you said there are 2 ways of approach......can you sen me the 2nd way of approach
The second apporach will require you to first find the sobject type from the provided record ID and then do do a SQOL query for that ID for its object type. And then you can display your data on your VF anyhow you like.
Actually my task is there are 6 objects obj1,obj2,obj3,obj4,obj5,obj6
in which obj1 has realtion with obj2 & obj2 has realtion with obj3
& obj3 has realtion with obj4 & obj4 has realtion with obj5 & obj5 has realtion with obj6
but when i paste an record id in the search box i must get the related lists of all 6objects in one page..............
Tell me this, when the user enters the record ID of any record that belongs to one of the 6 objects you mentioned, you want the related Records of all 6 objects or only the records of those objects which lie in the lower hierarchy?
I want the related Records of all 6 objects...................................