Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Here's something a bit crazy...

But - given a field "FirstName", shouldn't the following calculation return "FirstName" only? Instead it returns "T1A • MAIN CIND::FirstName" (TableName::FieldName)

Substitute (

GetLayoutObjectAttribute ("FilterSearch1 • " & Left(Get(LayoutTableName); 3); "source");

Case(Left(Get(LayoutTableName); 3) = "T1A"; Substitute (Left(Get(LayoutTableName); 3) & " • MAIN CIND::"; "T1A • MAIN CIND::"; "")

);"")

Posted

In the sample file attached you can see what I'm trying to accomplish. Clicking on the First Name filter works like a charm.

There's no values in the Last Name field to demonstrate the shortcoming in the Custom Dialogue which is presented if the user tries to execute the Last Name filter.

Filter.fp7.zip

Posted

In the sample file attached you can see what I'm trying to accomplish.

I'm afraid that's far beyond my capabilities. All I can see is that you are hard-coding the layout name (and other values) - but then you don't want them in the final result(?). If so, why use them as input in the first place?

Posted

I highly doubt that [beyond your capabilities], I'm sure it's just me making a mess... or taking seventeen detours to accomplish something very simple.

I have many tables in my database, all of which use up to seven such filters in list view. Feeling ambitious I wanted to have only ONE set of scripts that manages them all.

Each filter is tied to a specific filed. What field that is however varies from table to table.

Table 1: Filter 1 - First Name

Table 1: Filter 2 - Last Name

...

Table 2: Filter 1 - Shoe Size

Table 2: Filter 2 - Fruit Type

...

So... I've been trying to extract the field name of these fields and put them into a custom dialogue that shows when the filter can't work (no values available). But I only want the field name itself, not the entire string with the table name.

I know I'm very close - I seems I just didn't get the substitute quite right (I suspect).

WHERE TO FIND THE CODE IN QUESTION:

Script "Set Filters" - Line 8 and 20 (Custom Dialogues)

Posted

BTW, the Let() function is very useful in debugging a calc; instead of:


Substitute ( 

GetLayoutObjectAttribute ("FilterSearch2 • " & Left(Get(LayoutTableName); 3); "source"); 

Case(

Left(Get(LayoutTableName); 3) = "T1A" ; Substitute (Left(Get(LayoutTableName); 3) & " • MAIN CIND::" ; "MAIN CIND::" ; "");

) ;

"")




try:





Let ( [ 

object = "FilterSearch2 • " & Left( Get(LayoutTableName) ; 3 ) ;

source = GetLayoutObjectAttribute ( object ; "source") ; 

test = Left ( Get(LayoutTableName) ; 3 ) = "T1A" ;

...

...

] ; 

Substitute ( source ; searchString ; "" )

)

This way you can test each component separately.

Posted

I always knew I should know Let Functions better... very handy. I will see if I can't brake it down the way you suggested.

Posted

I have many tables in my database, all of which use up to seven such filters in list view. Feeling ambitious I wanted to have only ONE set of scripts that manages them all.

Why not use the field's name as the parameter, then? Although I am not sure how that would work, seeing you are also using a value list for each field. Perhaps you should just run the find with error capture on.

Posted

The value list is that users don't have to type into the filter field. This way they can (only) choose from a know to be valid set of values. Otherwise it would be more like a search field than a filter, I guess.

I could implement a custom function which allows for multiple parameters to be passed. That would make it even more complex though. Not that it isn't already...

Posted

SOLUTION (maybe not elegant, but works)

First define a variable with:

"This filter can't be used because the field " &  

Substitute ( 

GetLayoutObjectAttribute ("FilterSearch1 • " & Left(Get(LayoutTableName); 3); "source"); 

Case(

Left(Get(LayoutTableName); 3) = "T1A"; Left(Get(LayoutTableName); 3) & " • MAIN CIND::";

);

"")

& " contains no information in any of your records."




Then use this variable with a substitute function in the custom dialogue:


Substitute ($DialogueText; "MAIN CIND::"; "")

New file is attached - for the unlikely circumstance someone finds this useful...

Filter.fp7_2.zip

Posted

If the value list is empty, they cannot choose from it anyway. In any case, my point is that your method requires checking a specific value list for each filter field - thus making the script general enough to cover all fields in all tables more difficult. Although you could match the value lists names to field names.

I could implement a custom function which allows for multiple parameters to be passed.

I don't see why you would need more than one parameter.

Posted

Excellent point, I could use the field names for value list names. That would simplify everything a lot.

Posted

Wow, that's amazing - so simple.

You always do amaze me with your suggestions, comment. You really do.

Thank you!!

I hope I didn't keep you too long,

Michael

Posted

Just keep in mind that this method has a flaw: if you change the field's name, you must also change:

(a) the script parameter;

(:P the value list's name;

© the object name of the filter field.

(a) could be dealt with dynamically, but I don't see a good solution for (: and ©.

Posted

True. In my (cumbersome) method, I was able to change field names however I wanted to. I also instantly saw which filter a value list belonged to based on its name.

But you are saving a lot of code with your approach. These Filters are a lot of work to set-up anyway, so it doesn't matter that much.

Posted

Actually, I wasn't entirely correct: you CAN change the field's name and, as long as (a) = (:P = ©, it will keep working (except the custom message will not reflect the change).

This topic is 5248 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
×
×
  • Create New...

Important Information

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