function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mahi123Mahi123 

How can we go into next record and previous record when we click in Next pre buttons

Hi,

 

 I have two objects 1. Teacher(parent)  2. Subjects(child)---- Master Detail Relationship

 

When I am selecting one teacher I can see all the Subjects as related list. If I open 1st subject the page will navigated to Subject detail page. Here I want create 2 buttons 1. Next and 2. Previous

 

If I am clicking Next button then it should go to Next subject detail page if I am clicking on Previous button then I should navigated to Previous Subject

 

   Here for example Mahi teacher has 6 subjects if I open 1st subject if I click Next button I should navigate 2nd subject if I click Previous then I should navigated to 1st subject.

 

 I have done vf page

 

          

<apex:page standardController="Activitie__c" showHeader="true" sidebar="true" >
<apex:form >
<apex:commandButton value=" Next " />&nbsp;&nbsp;&nbsp;
<apex:commandButton value="Previous"/>
</apex:form>
<apex:detail relatedList="true" title="true"/>


</apex:page>

 

 

Any help is appreciated.

harsha__charsha__c

Hi Mahi

 

For this there is an approach given below

 

#1 The related must be custom, not by "relatedlist=true" in the page

#2 On click of any Subject, pass all the Ids of that related list to the Subjuct detail vf page through url param

#3 Store those ids in a list in the controller

#4 Define a Id variable which is get-set

#5 Store the index of list where Id of the clicked Subject is stored.

#6 On click Next/Previous increase/decrease index value, so correspondingly the value of variable defined in #4 changes.

 

Now make your apex:detail tag as

 

<apex:detail subject="{!idSubject}" relatedlist=.../>