Jump to content

Quick "drop down" to search field based on a value list, how?


Morenomdz
 Share

This topic is 2799 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have many records on a single List View layout, I want to be able to quickly show only the records based on this specific field called "store", on that field I have set a value list. So the idea is, a drop down list that when I chose one from that list will show all records with that criteria on the "store" field. Without changing the record data on that field permanently, just to filter by.

Right now I am trying with OnObjectModify but couldn't figure out a script that does a search specific on that field using the item selected on the value list drop down.

Help is apreciated, thank you very much once again!

Link to comment
Share on other sites

The closest way I got so far is:

I set the first record as a dummy for the search by "store";

 

OnObjectEnter it goes to the first record;

 

OnObjectModify it saves the record (it doesn't matter as it is a dummy record just for that) then perform a Find Matching Records [Replace] that then does show only the "stores" I selected on the drop down from the value list.

 

The thing is, can I hide that first record from ever showing on that layout? Will this way be safe to use or could somehow this method allow to select a different record and change and save the wrong info? It is very important that the field is never changed from that layout on the rest of the records but the dummy. Thanks.
 

Link to comment
Share on other sites

show only the records based on this specific field called "store",  So the idea is, a drop down list that when I chose one from that list will show all records with that criteria on the "store" field. Without changing the record data on that field permanently, just to filter by.

 

Find Matching Records works if the value you wish to find is in the current record you are viewing but if it is a value from a value list then another approach might be worth considering:

 

Create a global text field and place it in the header of your List view.  Attach your value list to it.  Attach script as trigger OnObjectModify and script would be (pseudo-script):

Enter Find Mode [ uncheck pause ]
Set Field [ table::field ; global ]
Set Error Capture [ on ]
Perform Find [ ] 
If [ not Get ( FoundCount ) ]
Show Custom Dialog [ No records found ]
End If
Link to comment
Share on other sites

Thanks I can go on from that! :D

 

Edit: I kinda got stuck, 

Enter Find Mode [ uncheck pause ]
Set Field [ table::field ; global ]
Set Error Capture [ on ]
Perform Find [ ] 
If [ not Get ( FoundCount ) ]
Show Custom Dialog [ No records found ]
End If

The script I get only set "Set Field [ table::field]" not global, then the script does nothing, not even the foundcount dialog it should show up. Ideas where I am messing up?

 

Thanks.

Link to comment
Share on other sites

A few things to consider:

  1. Are you going to the layout where you wish to perform the find?
  2. In your script Set Field[] has two parts - the first where you select the field to set and the second, separate button where you indicate the value.  Re-check you have both parts specified.
  3. Are you sure your global field is set to be global?  Check its field definition.
  4. You have FMPA (the Advanced version) so use debugger and step through the script and see where it breaks.

If you are still stuck, please post your real exact script for us to review.  You can print the script to PDF or Preview/copy it.  Posting a copy of the script I provided you does us no good.  :-)

Link to comment
Share on other sites

One small thing, with the said script, that is working right now, can I set it to filter the exact match of the vale? I have two stores with same name just change the city:

 

"Game Zone" and "Game Zone Centro"

It shows records from both when I select "Game Zone" from the drop down list, I tried to set the Perform Find step to show exact match for the field(= or ==) but that broke the script so I had to go back. Ideas?

Thanks again!

Link to comment
Share on other sites

I want to be able to quickly show only the records based on this specific field called "store", on that field I have set a value list. So the idea is, a drop down list that when I chose one from that list will show all records with that criteria on the "store" field. 

 

 

Two options:

 

Option 1:  Stores as an entity

You should have a Stores table where each of those stores are a separate record and contains a field called ID (known as the primary or parent key) which is meaningless auto-enter serial and the store name. Then your Stores value list should be based upon the Stores ID (values from field and all values), selecting the ID in the left pane and the description in the right.  Below, only show records from second field.

 

Then when User selects from Store pop-up, they are actually selecting (and inserting) the store's unique ID into the field.  What I'm saying is that you should store the store's ID and not it's name multiple times.  If you ever change the store's name, this table StoreName field will not be in sync.  And this means that when you select from the pop-up of Stores, you will only get one store's records because it is finding the unique ID for that store instead of a name.

 

Option 2:  Finding 'unique'

You were close on the find ... change your Set Field[] step to:

Set Field [ table::field ; "==" & global ]

Keep in mind that using == means the search is not optimum so it is best to approach this by the first option.

 

Corrected wording in blue bold.

Edited by LaRetta
Link to comment
Share on other sites

Worked perfectly. Thanks again!

I am trying to get this same method to work, but this time to filter by "month" showing just the records in that specific month from a value list. I tried to set the value list to "1/*/2015" and similar values on an similar script with a new global field, but it keeps saying the date format is wrong. Do you think that same method will work for a "drop down by month" option?

Link to comment
Share on other sites

There is no reason you can't include dates and ranges in your find.  There are MANY approaches you can use.  The simplest would be to create two new globals, gMonth (number) and gYear (number).  You don't need to create custom value lists for them but you can if you wish.

 

Then modify your script by adding another Set Field[] along with finding by the store, similar to:

Set Field [ yourDate ;

Let ( [
firstDay = Date (  Globals::gMonth ; 1 ;  Globals::gYear  ) ;
lastDay = Date (  Globals::gMonth + 1 ; 0 ;  Globals::gYear  ) 
] ;
firstDay & ".." & lastDay
)

The reason I do not like to use "1/*/2015" or anything similar is because doing so creates text dates and it is safer if you always use date functions when manipulating dates.  

Link to comment
Share on other sites

BTW, I did not include any test to be sure date values were included.  As it stands, if no month and year are entered, it will break.  Your script can test, similar to:

If [ not gMonth and gYear ]
# User entered year but no month so assume all months for the year
Set Field [ yourDate ; gYear ]
Else If [ gMonth and gYear ]
# User entered values for both month and year
Set Field ... as I've indicated in post #15
Else If [ gMonth and not gYear ]
# Not valid so tell the User
Show Custom Dialog [ "If you enter a month you must also enter the year"]
Exit Script
End If

You may wish to assume current year if the User doesn't enter a year.  As said, there are hundreds of variable methods for presenting search capabilities to the User but this should get you going. :-)

Link to comment
Share on other sites

This topic is 2799 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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