db_tragic Posted March 6, 2013 Posted March 6, 2013 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
bcooney Posted March 6, 2013 Posted March 6, 2013 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.
db_tragic Posted March 7, 2013 Author Posted March 7, 2013 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)
bcooney Posted March 7, 2013 Posted March 7, 2013 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 isjigsaw Posted March 11, 2013 Newbies Posted March 11, 2013 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
db_tragic Posted March 12, 2013 Author Posted March 12, 2013 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!!
bcooney Posted March 12, 2013 Posted March 12, 2013 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.
db_tragic Posted March 14, 2013 Author Posted March 14, 2013 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,
db_tragic Posted March 18, 2013 Author Posted March 18, 2013 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.
bcooney Posted March 18, 2013 Posted March 18, 2013 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.
db_tragic Posted March 19, 2013 Author Posted March 19, 2013 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.
Recommended Posts
This topic is 4265 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now