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
Ricky 007Ricky 007 

How to see next and previous record using button in detail page

Hi,

I am new to salesforce and i am facing an issue, 

The scenario is:
 
 I have two objects 1. Pricing Agreement(parent)  2. Contract Item(child)---- Master Detail Relationship
 
When I am selecting one Pricing record I can see all the contract item as related list. If I open 1st record the page will navigated to contract item detail page.
I want to create 2 buttons  Next and  Previous
 
If I am clicking Next button then it should go to Next Contract Item detail page if I am clicking on Previous button then I should navigated to Previous Contract Item Detail Page.

I want this to be done in Lightning.

Any help would be appreciated.
Thanks in advance.

 
Amol Shivaji RokadeAmol Shivaji Rokade
Hi,
You can not achieve this functionality using OOTB related list.
You can create one custom lightning component to display Contract Item as related list.
Create 2 Map
Map<String,String> SequenceNoToContractItemRecordId
Map<String,String> ContractItemRecordIdToSequenceNo

Say you have 3 line Item 
then with Record Id X,Y,Z

Consider in your related list contract item will be in below sequence:

Y
Z
X

then your first Map will be like this SequenceNoToContractItemRecordId ={1=>Y,2=>Z,3=>X} and 2nd map will like ContractItemRecordIdToSequenceNo={X=>3,Y=>1,Z=>2}


If you click on Y record you will be on detail page of contract Item whose record ID is Y and on click of Next button you want to move on  contract Item whose record ID is Z.Once you are on on detail page of contract Item whose record ID is Y
you will get Record ID as Y pass this Record ID to ContractItemRecordIdToSequenceNo Map as key,you will get sequnce no as 1.On click of Next button just increment counter of sequence by 1 in this case it will 2.Now you have sequence no as 2
pass this sequence no as key to SequenceNoToContractItemRecordId you will get recordId as Z  and display this contract Item.On click of back button decrement counter by 1.

Hope this will resolve your problem.In case of question,please revert back.

Thanks