MacSig Posted June 27, 2009 Posted June 27, 2009 Hello guys, Currently I'm working on my first FM (FM9) project: updating a old FM5 solution. Right now the users are still performing some operations through the status area but I want to hide it in the version I'm working on so I need to implement a finding feature. I have already used the find steps in my project but usually with only 1 parameter (for instance to find all the document with a specific expiration date). My question is how can I implement a complete finding feature? I mean I want to have a layout with a dozen of fields and the user can input any combination of those and when he/she clicks a button I want to return him/her the list of the records that match all the input fields. Basically exactly what happens when the user selects find mode in the status area, inputs some values and clicks "find". Do I have to create a parameter that contains all my fields, split them at the begin of my script into a bunch of variables and after that to perform a find using those variables or there is a better way to deal with this issue? Thanks for your help. I appreciate it. Sig
bcooney Posted June 27, 2009 Posted June 27, 2009 (edited) I dedicate a layout for Find for each table, that is basically a duplicate of the form view for that table. However, the Find layout looks different. Sometimes it has a red border so that the user knows they are in Find mode. The form and list views have a button "Find" with a script parameter, that performs the following Find Script: If [(Get(Scriptparameter) = "Cancel"] Go to Layout [$$startLayout] Enter Browse Mode If (Get (foundcount) = 0 Show All Records End If Exit Script[] End If Set Variable $$startLayout, Value: Get (LayoutName)] If [Get (ScriptParameter) = "Client" ] Go to Layout ["Client_Find"] End If Enter Find Mode Go to Object [Object Name: "find"] //we name the field that we want the user's cursor to default to Pause/Resume Script [indefinitely] // the Find layout has two buttons "Cancel" and "Perform Find" // Perform Find is set to Resume Script // Cancel is set to Exit Script // Cancel runs the Find script, but with the scriptparameter "Cancel" Perform Find If ( Get (foundcount)= 1 go to layout (Form) ElseIf (Get (foundcount) >1 go to list Else //foundcount = 0 go to layout $$startLayout Show Dialog (No Records Found) Try Again Cancel If [Get (LastMessageChoice)=1 //Try Again] Perform Script ["Find" ; Parameter: Get (ScriptParameter)] Else Show All Records End If End If Edited June 27, 2009 by Guest
MacSig Posted June 28, 2009 Author Posted June 28, 2009 thanks for you reply. So you perform the find without setting any fields. Is this correct? Does FM find the matching records without setting any fields? Thanks again.
IdealData Posted June 28, 2009 Posted June 28, 2009 No, the user must input the find criteria - that's why there is a PAUSE in the middle of the script. I use the same methods my self.
MacSig Posted June 29, 2009 Author Posted June 29, 2009 Thanks, I don't understand well how the pause works. This is my scenario: I have a dashboard layout with a "find" button, when the users clicks it he's redirected to an finding layout (that has all the fields my table has) on find mode. This happens through a script at this point the script goes on pause. On finding layout I have an other button, then the user clicks it the script is resumed, it performs the finding, and it shows the matching records. Is this correct ? Thanks again.
bcooney Posted June 29, 2009 Posted June 29, 2009 That's exactly what my script does. Click Find, go to Find layout, enter Find Mode, pause (user enters search criteria), click button set to resume, script's next step is to perform find and return to appropriate layout. (I also have a Cancel button).
MacSig Posted June 30, 2009 Author Posted June 30, 2009 I have an extra question: why do I need to pause the script? I mean I can make it works even without so, why do I need it? Thanks
bcooney Posted June 30, 2009 Posted June 30, 2009 How does it possibly work if you don't pause and let the user input search criteria?
MacSig Posted June 30, 2009 Author Posted June 30, 2009 I simply do something like: if 1 go to layout 1 enter find mode elseif 2 perform find go to layout 2 enter browse mode end and I call it with 1 on my dashboard and I call it with 2 on find layout. Am I missing something? Thanks
MacSig Posted July 1, 2009 Author Posted July 1, 2009 it works so I will keep it as is have a good 1!
bcooney Posted July 1, 2009 Posted July 1, 2009 Sorta following what you have. If 1 //does that mean the scriptparameter is 1? Your button on Find sends scriptparameter "2", and the button is set to exit current script? How do you handle no records found? Do you give the user a choice to Try Again? Can they Cancel once in Find mode and return to their starting layout? How will you adjust your script to handle incoming find requests from other tables?
MacSig Posted July 1, 2009 Author Posted July 1, 2009 Sorta following what you have. If 1 //does that mean the scriptparameter is 1? Your button on Find sends scriptparameter "2", and the button is set to exit current script? How do you handle no records found? Do you give the user a choice to Try Again? Can they Cancel once in Find mode and return to their starting layout? How will you adjust your script to handle incoming find requests from other tables? the script sends the user back to the layout where I have the "go to find" button. If no records are founded the user can perform and other find. They cannot cancel the find, I'm working on that right now. I didn't say my script is the best way to deal with this issue but I have some problem with pause, I can't resume it: when I try to do so the script is called once again from begin. Here my actual code: Set Variable [ $Button; Value:Get ( ScriptParameter ) ] #---------------------------- If [ $Button = "GoToLayout" ] Go to Layout [ “Procedure (find)” (Procedures) ] Enter Find Mode [ ] Pause/Resume Script [ Indefinitely ] Else If [ $Button = "PerformFind" ] Perform Find [ ] Go to Layout [ "ProcedureList" & Get(PrivilegeSetName) ] Go to Record/Request/Page [ First ] Enter Browse Mode End If when I call the script once it goes on the right layout but when I input the fields and I call it the second time on the status area I still have the button to resume it. Because of that I tried without pause and looks like it works. Thanks again for your help Barbara, I appreciate it. Have a nice day!
mr_vodka Posted July 1, 2009 Posted July 1, 2009 (edited) Okay here is the confusion. You are only using one script. Barbara's example uses two. Here is the second script which actually does the find. Pay attention to the bolded parts. When you specify the button, there is a drop down that lets you choose what do do with the current script. It default to pause I believe but there are options for halt, exit, and resume as Barbara's example uses. // the Find layout has two buttons "Cancel" and "Perform Find" // Perform Find is set to Resume Script // Cancel is set to Exit Script // Cancel runs the Find script, but with the scriptparameter "Cancel" Perform Find If ( Get (foundcount)= 1 go to layout (Form) ElseIf (Get (foundcount) >1 go to list Else //foundcount = 0 go to layout $$startLayout Show Dialog (No Records Found) Try Again Cancel If [Get (LastMessageChoice)=1 //Try Again] Perform Script ["Find" ; Parameter: Get (ScriptParameter)] Else Show All Records End If End If Edited July 1, 2009 by Guest
MacSig Posted July 1, 2009 Author Posted July 1, 2009 thanks for your reply. how do I resume the paused script? Can I use only a script instead two? if so what is wrong with my script? Thanks again.
bcooney Posted July 1, 2009 Posted July 1, 2009 No, I don't use two scripts. I use one Find script. The button on the Find layout is set to the Resume/Pause script step. The Cancel button is set to Exit current script, but runs the Find script also. It has a button script parameter "Cancel." I need to put this in a demo. MacSig. Your script leaves the user in Find Mode. However, what if they press enter on their keyboard. What happens? Are they dumped into Browse mode on the Find layout?
MacSig Posted July 1, 2009 Author Posted July 1, 2009 the script leaves the user in Find Mode because the user has to input the fields to use for the finding. I haven't checked out yet what happens when the user presses enter. My current issue is to understand how to resume correctly the script when the user presses "perform script". Going back to my script Set Variable [ $Button; Value:Get ( ScriptParameter ) ] #---------------------------- If [ $Button = "GoToLayout" ] Go to Layout [ “Procedure (find)” (Procedures) ] Enter Find Mode [ ] Pause/Resume Script [ Indefinitely ] Else If [ $Button = "PerformFind" ] Perform Find [ ] Go to Layout [ "ProcedureList" & Get(PrivilegeSetName) ] Go to Record/Request/Page [ First ] Enter Browse Mode End If [code] Let us say for one minute we are in a prefect world where users do exactly what they are supposed to do. In the main layout they press the button "Go To Find Mode": - the script is called with GoToLayout as parameter, - they are redirect to Procedure (find) layout - they are on Find Mode - the script is paused At this point they input the fields they wish and they press the button "Find": - the script is called with PerformFind as parameter - the script should be resumed (How to do that???) - the find is performed - they are redirect to the specific layout ... With my script when I execute for the second time the script (on find layout) the script doesn't resume but it begin once again and I still have a script on pause. How can I resume it? Thanks, I do appreciate your help.
bcooney Posted July 1, 2009 Posted July 1, 2009 I think something that you're missing is the use of Resume Script in the Button Setup dialog. By placing a button with this behavior on a layout, your user can continue (Resume) a paused script. That is what I do in my find script. I name the button "Perform Find", but all it does is exit the pause and resume the Find script. Now the Cancel button on my Find layout is set to Perform Script "Find" with the Option to Exit current script. This exits the pause and restarts the Find script. The cancel button passes a parameter of cancel, so the Cancel section of my script runs. hth btw: I believe that 95% of FM developers have a Find script that is identical, if not close, to my script. I know that you want to see your script work, but I believe you'll end up with something like mine.
MacSig Posted July 2, 2009 Author Posted July 2, 2009 I guess I got it now. What I was missing was the "resume script" for the "Find" button. using this option the paused script (since it doesn't need to select any script I think it knows which script is paused) is resumed and executed from the step after the Pause/Resume Script[indefinitely] step. Is that correct? Am I missing something else in my script?
MacSig Posted July 2, 2009 Author Posted July 2, 2009 How do you handle the option to exit the finding (through a cancel button)? I can't understand it from your script. Since Resume script can't accept any parameters I can't put a if after the pause in order to know if I have pressed "Cancel" or "Find". Thanks
bcooney Posted July 2, 2009 Posted July 2, 2009 You understand the use of a Resume script button. It'll help you whenever you write a script that pauses and that you wish to continue, such as a Find. Sometimes, I write scripts that end with a Pause. The buttons on the layout then Perform script with behavior of Exit current script. Think of it as cancelling the Pause, and starting something new. When you popup a new window as a dialog, you typically Pause (so that the window is modal-user can't click elsewhere). That window needs at least a Resume button which would continue the script that started the popup window, do stuff, and close the window. What if you wanted to popup a window, Pause for data entry, and go off and do another script and come back to the pause? Then you'd use the button option for Pause current script. Managing pauses is challenging at times. Here's a demo that makes use of pauses and button behavior. NotePopup.fp7.zip
bcooney Posted July 2, 2009 Posted July 2, 2009 The cancel button is set to Perform Script "find" with Exit current script as the button behavior (this stops the current pause). Notice how I look for Cancel at the top of the Find script, and that I have an Exit Script() step in the conditional section. So, my Find script doesn't continue past that point if the user clicked cancel.
bcooney Posted July 2, 2009 Posted July 2, 2009 Not to add to the confusion, but to help you see how easy it'll be to use this find script across your entire system, this section usually becomes: Set Variable $$startLayout, Value: Get (LayoutName)] If [Get (ScriptParameter) = "Client" ] Go to Layout ["Client_Find"] ElseIf [Get (ScriptParameter) = "Invoice" ] Go to Layout ["Invoice_Find"] ElseIf [Get (ScriptParameter) = "Product" ] Go to Layout ["Product_Find"] . .//adding ElseIf's as needed . End If
MacSig Posted July 2, 2009 Author Posted July 2, 2009 got it. thanks again for your help. Thanks also for the popup tip, I can't use popup (since I work exclusively with IWP) but I got the idea. Have a good evening.
Brudderman Posted July 2, 2009 Posted July 2, 2009 I need to put this in a demo. I'd love to see that demo if you ever get time. : James www.james-mc.com
bcooney Posted November 24, 2010 Posted November 24, 2010 Finally had time for this demo. FindDemo.fp7.zip
Brudderman Posted November 24, 2010 Posted November 24, 2010 Thanks so much for the demo!! James www.james-mc.com Words To Live By
Recommended Posts
This topic is 5111 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