Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Search based on custom date range

Featured Replies

Hi folks, I'm planning to create a button on an existing layout that will take the user to a new window (all on FM Go) where they can enter a date range to search for invoices. I.e. Set a start date, set an end date, then show a list of all invoices in that date range. Still a relative noob, but particularly to setting up custom searches. Firstly, I'm after ideas on the most efficient way to step this through, and of course details on the steps themselves. No experience with calculations as yet. TIA

Solved by db_tragic

Go to solution

To search for a date range, the user should be taken into Find mode (perhaps on a dedicated layout) that has the required date field. They'd simply enter the date range as a find criterion (1/1/13..3/1/13) for example.

  • Author

To search for a date range, the user should be taken into Find mode (perhaps on a dedicated layout) that has the required date field. They'd simply enter the date range as a find criterion (1/1/13..3/1/13) for example.

 

 

OK, so they go to a new layout in Find mode, which has the fields "Date" "Surname" "InvoiceItem" "Balance".

 

On the ipad they tap on the Search menu item (bottom right) and select "Enter Find Mode",

 

then in the date field, select the start date using the pop-up calendar wheel thingy

 

then type "..." ('range' operator)

 

then manually enter the 'end' date (can't use the calendar wheel cause it simply overwrites the existing content).

 

Question: What is a better way to have the user enter the start and end date of a search? (for iPad platform)

Another way is to create two global fields for the start and end date respectively.

 

Two scripts. The first simply goes to the "find" layout in browse mode. On this layout are the global fields.

 

Second script enters Find mode and sets the fields to the global values, performs the find and takes user to result (list) layout.

 

Use the construct:

Enter Find Mode

Set field (my field, myglobalstart & "..." & myglobalend)

Perform Find

If getfoundcount

Go to MyListLayout

else

go to mystartinglayout

endif

  • Newbies

Here is how I did something simular...

 

Set Field [student Info::g_End;””]

Set Field [student Info::g_Start;””]

Show Custom Dialog [“Criteria Needed”; “What months do you wish to search for?”; Student Info::g_Start; Student Info::g_End]

Commit Records/Requests

Enter Find Mode

Set Field [student Info::Student Month; Student Info::g_Start &”…”& Student Info::g_end]

Perform Find

 

The g_End and g_Start fields are global fields

  • Author

Another way is to create two global fields for the start and end date respectively.

 

Two scripts. The first simply goes to the "find" layout in browse mode. On this layout are the global fields.

 

Second script enters Find mode and sets the fields to the global values, performs the find and takes user to result (list) layout.

 

Use the construct:

Enter Find Mode

Set field (my field, myglobalstart & "..." & myglobalend)

Perform Find

If getfoundcount

Go to MyListLayout

else

go to mystartinglayout

endif

 

Thanks bcooney. Looks like it's on the right track - just having an issue with the "target" not being found when running the script. Will recheck my script and see where I've gone wrong.

 

Appreciate the help.

 

Here is how I did something simular...

 

Set Field [student Info::g_End;””]

Set Field [student Info::g_Start;””]

Show Custom Dialog [“Criteria Needed”; “What months do you wish to search for?”; Student Info::g_Start; Student Info::g_End]

Commit Records/Requests

Enter Find Mode

Set Field [student Info::Student Month; Student Info::g_Start &”…”& Student Info::g_end]

Perform Find

 

The g_End and g_Start fields are global fields

 

Thank you for that - haven't used the 'commit records/requests' function before - will have a look into that one too.

 

 

.....so many ways to skin a cat...........ESPECIALLY in FM!!

Target not found is typically an indication that you are attempting to Set a field when you aren't on the correct layout (context). Also, to surpress FM's error messages, you can add Set Error Capture [on] to the top of the script. Keeping it off while you debug your script is very useful.

  • Author

Target not found is typically an indication that you are attempting to Set a field when you aren't on the correct layout (context). Also, to surpress FM's error messages, you can add Set Error Capture [on] to the top of the script. Keeping it off while you debug your script is very useful.

Thanks again,

 

Haven't had a chance to chase this up, but based on what you said, I have an idea where I've gone wrong.

 

Have more to learn re Error Capture settings, however what you say makes sense.

 

Cheers,

  • Author

Seem to be having some trouble with this. Here are my two scripts as follows.

1. This one simply takes the user to a layout where they enter the global values for start and end dates for the search range.

Go to Layout ["Date Range Global" (Date Range Global)]

Enter Browse Mode []

Should this layout be based on the Invoice List table, or just the Date Range Global table containing the 2 global fields used here?

2. This script then performs the search, as suggested, but isn't working for me. (It is applied to a "Start Search" button on the previous layout where the global values are set for start/end date.)

Go to Layout ["Invoice Date Range List" (Invoice)]

Enter Find Mode

Set Field [invoice::Date; Date Range Global::gStartDate & "..." & Date Range Global::gEndDate]

Perform Find []

If [Get(FoundCount)]

Go to Layout ["Invoice Date Range List" (Invoice)]

Else

Go to Layout ["Home" (Client Details)]

End If

I'm sure there's something fundamental going on here that I'm doing incorrectly. Not sure if I have the correct starting layout for this script (which is the same layout that the found set will appear on). At this point, the search isn't returning the date range I ask for, (seems to be continually showing the results of a manually entered date range from earlier (i.e. "startdate...enddate" - which does work when entered manually ).

Any help greatly appreciated.

Hmm..not seeing where you're going wrong here. Have you extra double-checked that gStartDate and gEndDate are set to global storage. Many a time I've named the fields gSomething, and forget to really set them to global storage.

 

Since you're on the correct list layout, you don't need the If construct. Simply, if Get (found count) =0 go to layout "home". I usually show a message first. Retry..etc.

  • Author
  • Solution

OK - got it sorted, in fact using BOTH the suggested methods above (Thanks to bcooney, and isjigsaw).

 

My mistake was that the layout "Invoice Date Range List" was based on the wrong table that's all. The script above shows it being based on the Invoice table, when in fact, it should have been the next table level up - which I found based on a hunch - no blinding flash of brilliance or logic on my part!!

 

Thanks again bcooney, and isjigsaw for your input. 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.