December 31, 201411 yr Hi Folks, I've got a couple of search boxes on the home page which all work fine. When there are no results, I have no problem leaving find mode and returning back to the original layout, but this could cause jitters for my colleagues. I've attempted to set up a way to trigger a custom dialogue if that happens, but I've never done this before and can't get it to work. I can see problems with the attempt below but have brain fade in fixing it! I think I need to use something like: If FoundCount=0 then goto dialogue box Else exit script? Enter Find Mode [ ] Go to Layout [ “Pupils” (Pupils) ] Set Field [ Pupils::FullName; Pupils::gPupilFind ] Set Error Capture [ On ] If[Get(FoundCount) =0] Perform Find [ ] Go to Layout [ original layout ] Show Custom Dialog [ Title: "No matches"; Message: "No matches found for " & Quote ( Pupils::gPupilFind); Default Button: “OK”, Commit: “No”; Input #1: Pupils::gPupilFind, "Find:" ] End If A nice touch would be the ability to alter the find string from the dialogue box and search again.. Many thanks, Mike
December 31, 201411 yr Get (FoundCount) while still in find mode returns the number of existing find requests so the perform find, Go to layout, Show custom dialog script steps will never execute in your version. My guess is that you want to Enter Find Mode [ ]Go to Layout [ “Pupils” (Pupils) ]Set Field [ Pupils::FullName; Pupils::gPupilFind ] Set Error Capture [ On ] Perform Find [ ] Set Error capture [Off]If[Get(FoundCount) =0] Go to Layout [ original layout ]Show Custom Dialog [ Title: "No matches"; Message: "No matches found for " & Quote ( Pupils::gPupilFind); Default Button: “OK”, Commit: “No”; Input #1: Pupils::gPupilFind, "Find:" ]End If You might want to think about how you will handle the missing Else or Else If clause in your script. You have handled the case where found count is zero.. but what if found count is exactly one? What if found count is more than one? it is common to put the user into a list layout if more than one record is found and put them into the detail layout if only one record is found.
December 31, 201411 yr Author Hi Kris, Many thanks, that's got it working. Now to learn how to use the custom dialog... Cheers! Mike
December 31, 201411 yr Kris, I don't see the point in SetError Capture (Off) Rick, When I explicitly supress errors using Set Error Capture[On] I only keep them surpressed for as long as absolutely necessary.
January 2, 201511 yr Author Hi folks, If come up with this script which works - the custom dialogue gives the option to change the search. It's the first time I've Else / If type stuff and I'm pretty sure my loop could be simplified, (I've not done anything like this since I was a kid working with BBC Basic!!) If anyone has improvements on my rough conditional branching I'd be grateful :-) Enter Find Mode [ ] Go to Layout [ “Pupil List” (Pupils) ] Set Field [ Pupils::FullName; Pupils::gPupilFind ] Set Error Capture [ On ] Perform Find [ ] Set Error Capture [ Off ] If[Get(FoundCount) =0] Go to Layout [ original layout ] Show Custom Dialog [ Title: "No matches"; Message: "No matches found for " & Quote ( Pupils::gPupilFind); Default Button: “OK”, Commit: “No”; Button 2: “Look again”, Commit: “Yes”; Input #1: Pupils::gPupilFind, "Enter new search:" ] If [ Get ( LastMessageChoice ) =2 ] Perform Script [ “Find Pupil” ] End If End If
Create an account or sign in to comment