Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Auto-Sorting By Date on Performing a Search


lostatsea

Recommended Posts

When performing a search using a range of dates (where the 'date' field is actually just text) I notice that the records are not sorted by date. Is there a way to ensure that my results are automatically chronoligical by date and not have to sort them manually?

 

Thanks.

Link to comment
Share on other sites

Use a script to perform the search followed by the sort. Maybe something like this:

 

Go to Layout[Find]

Enter Find Mode[]

Pause Script[]

Set Error Capture[On]

Perform Find[]

If[get(lasterror)=401]

Show Custom Dialog["No records found";"Ok"]

Perform Script[Find]

Exit Script

End If

Go to Layout

    Sort Records[No dialog; by Date]

     

    BTW: Your "Date" field should really be a date field, not text, if you want it to sort correctly.

Link to comment
Share on other sites

At the moment, we are performing the search by navigating to:

1. Find Mode

2. Entering the selected search critiera in the 'Next Due Date Field'

3. Hitting 'enter'.

 

Would I have to create a button in order for the above script to work, or is there a way to initiate the script on hitting 'enter' while in the field?

 

Thanks!

 

PS. It's true, what you say about changing it to a date field, although I am worried about all of the data that exists in this field currently. It exists as: yyyy/mm/dd and I am a bit leary about changing the type and risk screwing something up.

Link to comment
Share on other sites

Use a button on the layout and have it Perform the Find script.

 

PS. It's true, what you say about changing it to a date field, although I am worried about all of the data that exists in this field currently. It exists as: yyyy/mm/dd and I am a bit leary about changing the type and risk screwing something up.

You can convert your date text to Date format by using the text functions. Maybe something like:

 

let(

text = substitute(field;"/";" ");

date(middlewords(text;3;1); middlewords(text;2; 1); middlewords(text;1;1))

)

 

Put the dates into a new Date field first using a Replace Field Contents, then change the original field to be a Date type, and use another Replace Field Contents to move the new dates into the old field (be sure to make a backup prior to messing with this).

 

With your dates in an actual date field, it will be easier to perform calculations on them in the future. You can always display them however you wish using the Date Format options.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

Terms of Use