go to previous and next record for Child record Detail page

  • 2
  • Question
  • Updated 1 year ago
  • Answered
Hello,

Did anyone ever figure out a way to navigate from 1 child record to another right from the Detail page of that child?

Example I have an account with multiple contacts

I would like to find a way that when i open the detail page of a contact, to be able to navigate to previous and next related contact(s), using something like a "wizard" step or similar

The sort order would be created date


Thank you
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb

Posted 3 years ago

  • 2
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Create a model for each direction where the condition is less than or greater than on the created date with the field CreatedDate used to sort and return one record adjacent to the current record based on CreatedDate. Set both to load on page load.

Then redirect to these records using Redirect Action on {{$Model.PreviousRecord.data.0.Id}} & {{$Model.NextRecord.data.0.Id}}
Photo of Jamie Crawford

Jamie Crawford

  • 486 Points 250 badge 2x thumb
Hi Pat - can you clarify how you "return one record adjacent to the current record based on CreatedDate"? 

I have the models and conditions set up, but need to activate this next step. 

Thanks!
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
The NextRecord and PreviousRecord Model are used in Redirect actions.
/{{$Model.NextRecord.data.0.Id}}
/{{$Model.PreviousRecord.data.0.Id}} 

Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Pat you are truly a champion

Thank you very much, it worked perfectly!
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
The date makes sense.  Any ideas on if the next record needs to the next record in alphabetical order?
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
A typical user will see 200 or less records.  I tried doing it the same as the date method.  The next button appears to work perfectly using that method.  The last button goes back to the first client in the row.  
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
Any chance you can help me out with the snippet.  I am hindered by my lack of coding skills.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Sure. Invited you on Google Hangouts.
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
Thanks Pat!  We did it without a snippet.  It is awesome.  Greater and Less than work with Alphabetical lists too.  And then we just conditionally Enabled the buttons so that if there is no data rows you can't click on the button but it still appears.  I will show the details in case someone else is working on a similar problem.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Your welcome. :)