How to get the closest date record before the current date record using workflows(preferably) ?
For e.g. A record is created with status as "Open". On click of a button a program should be invoked(workflow or script) to fetch the most recent records with status as "Open".
That means if a new record is created today and already there are 3 records with same status as "Open" with two created yesterday and one created 2 days before.Then our program should fetch only those two records created yesterday and not the one created two days before.
The simplest solution I can offer is:
Add a search spec on the BC for Status="Open" and add a Sort Spec on the BC for "Created Date (DESC)". When you query the BC, just focus on the first record which should be the most recent record in "Open" status.