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
itstaff1.3920641347534116E12itstaff1.3920641347534116E12 

Move to next Lead from existing Lead page

Hello,

  I am implementing a functionality in Salesforce which will allow for the users to move to the next or previous Lead from the lead page layout with the click of a 'Next' or 'Previous' button. Right now, it is looking at all the leads in the system to determine which record to move to. I would like to leverage the Lead view in order to determine the set of leads to navigate through.

My developer is telling me this is not possible, but I would like to exhast all resources.

Any suggestions or ideas are greatly appreciated.

Thanks.

Shanky
Elie.RodrigueElie.Rodrigue
Short answer is no you cant do that.
View filters are unaccessible from apex code.

There's some design solution you can use however : 
Use reports instead of views and figure out the next record using the analytics api (Kind of complex for your need)
You could hardcode some sorting methods, create a visualforce component that you include in the lead layout that allow you to select one of the sorting method and then click next of previous. (Much more simple)
You could use custom settings to define sort criteria and only have next / previous button in the lead (through custom buttons or visual force component) 

I hope this help

Elie
Offshore Freelance ConsultantOffshore Freelance Consultant
Hi,

This is a workaround.

1. Have a Visual Force Tab(next to leads).
2. Top of the Tab, have some filter crieria fields defined in the visual force page, like State = Picklist, Regision= Picklist Stage=picklist etc.(Predefined as per your business requirements).
3. First you set the filter criterial that you want to see the leads(here we are dynamically creating the view).
4. Also select Sort By field and then click Go button.
5. Underlying code will query leads and bring you a set of leads(with pagination).
6. the lead list will look similar to the lead view.
7. You click on any lead, (view or edit link), which will bring up the lead record details(underlying visualforce/apex code).
8. Do any operation as required(like setting stage, populating other fields etc.
9. Then you will see buttons like "Save", "Save & Go to Next Lead" "Save & Go To previous lead", "Cancel".
10. Depending on the button clicked appropirate action can happen(underlying visual force/apex code).

I see one technical issue in the above approach. When we query the lead object, if the number of records in lead are huge, the query may fail, because of lack of indexing. This can be overcome by properly indexing the lead object(by raising ticket with SFDC support) and by putting in relevant filter criteria.

Hope this helps!

JG
Jimmy SuhJimmy Suh
Can we add this feature as standard button?