What's a Custom Function you've created that you think should be built-in to FileMaker?

It seems many, like me, use custom functions that return a table name or an unqualified field name. I bet many, like me, use GetFieldName with these functions. I suggest you read the following post: Out of Memory Error. GetFieldName seems to have an unfortunate caveat.

Hope this helps.

1 Like

Re: "I love custom functions, that make FileMaker Code more human readable"
Me too. A couple of mine:
exists β€”> not IsEmpty ( theField )
defaultButton β€”> Get ( LastMessageChoice ) = 1
similarly, secondButton and thirdButton
noneFound β€”> Get ( LastError ) = 401
userCancels β€”> Get ( LastError ) = 1
and for use in FMGo on devices:
landscape β€”> Get ( WindowOrientation ) < 0
portrait β€”> Get ( WindowOrientation ) > 0

4 Likes

one that I did not create - but would be quite important here:

  • call FMS and lists currently active users (not just one file)

Means that we do not have to login on the admin-console..

Oh? What is the custom function and where can I obtain it?

I couldn't create that by myself until now, not sure how to get that (for all platforms). Have to investigate - maybe via shell scripting
)-:

@Markus @bdbd

A CF for that would be amazing (maybe it requires a plug-in?)

But if anyone's interested meanwhile, I recently wrote a little NodeJS script that runs from terminal or an app like Raycast (which I just started using and love).

node path/to/get-clients.js "myusername" "mypassword"

It prints the JSON output from the FMS Admin API followed by a more readable digest.

Be sure to open the js file in a code editor first and change the target server domain.

get-clients.js.zip (1.7 KB)

4 Likes

I have a script that formats US phone numbers and cleans up stray characters, and another which turns a gmail copied email ("Jane Doe jane@gmail.com") into just an email for easy pasting. I tend to use them in every app I make at some point. Ironically I usually also end up recreating them... I need to systematize that. at some point... :slight_smile:

2 Likes

I have a similar one, but for Australian phone numbers.

Can't believe I forget to mention this, but validating that a given string is valid JSON should also be native.

2 Likes

I just recently put this same idea on my personal to-do/wish list. I often find myself writing a series of steps to destructure Get(ScriptParameter) into variables and then perform separate checks on each var. A one-liner based on JSON schema sounds beautiful.

It might be slightly less efficient for the computer to read from the same JSON twice, once to validate and once to destructure, but, the DX improvement sounds worth it to me, and apparently has been for you!

I like that you have a suite of CFs to work with values..

" FileMaker Lists and Values are core features of the FileMaker Platform
β€’ Entering multiple checkbox choices creates a lists of values
β€’ Many Functions return lists of values, for example Get ( TriggerTargetPanel )
β€’ ValueListItems are list of values
β€’ There are lots of function for working with lists of values"

Here is one CF that I posted that is useful for working with lists of values:

value.index.ci ( a_list ; a_value )

Here is a list of others that would be suite:
image

1 Like

Likewise, date_time to text is useful...

// @format_date_time ( format ; date_time )
// based on: FormatTimestamp ( format ; tstamp ) on briandunning dot com/cf/629
// FileMaker Custom Function: FormatTimestamp ( format ; tstamp )
// minor mods by twdesigns.com
// Formats a timestamp, date, or time according to format, replacing placeholders with date and or time strings.
// If date_time is empty (""), then the current date and/or time are used.

Let (
[
~date_time =
Case (
date_time = "" ; Timestamp ( Get ( CurrentDate ) ; Get ( CurrentTime ) ) ;
date_time ) ;

~hr = Hour ( ~date_time ) ;
~hr12 = Mod ( ~hr - 1 ; 12 ) + 1
] ;

Substitute ( format ;
	[ "[HH]" ; Right ( "0" & ~hr ; 2 ) ] ;
	[ "[H]" ; ~hr ] ;
	[ "[hh]" ; Right ( "0" & ~hr12 ; 2) ] ;
	[ "[h]" ; ~hr12 ] ;
	[ "[mm]" ; Right ( "0" & Minute ( ~date_time ) ; 2 ) ] ;
	[ "[m]" ; Minute ( ~date_time ) ] ;
	[ "[ss]" ; Right ( "0" & Seconds ( ~date_time ) ; 2 ) ] ;
	[ "[s]" ; Seconds ( ~date_time ) ] ;
	[ "[am_pm]" ; If ( ~hr < 12 ; "am" ; "pm" ) ] ;
	// [ "[am]" ; If ( ~hr < 12 ; "am" ; "pm" ) ] ;
	// [ "[pm]" ; If ( ~hr < 12 ; "am" ; "pm" ) ] ;
	[ "[AM_PM]" ; If ( ~hr < 12 ; "AM" ; "PM" ) ] ;
	// [ "[AM]" ; If ( ~hr < 12 ; "AM" ; "PM" ) ] ;
	// [ "[PM]" ; If ( ~hr < 12 ; "AM" ; "PM" ) ] ;
	[ "[Dayname]" ; DayName ( ~date_time ) ] ;
	[ "[dayname]" ; Lower ( DayName ( ~date_time ) ) ] ;
	[ "[DAYNAME]" ; Upper ( DayName ( ~date_time ) ) ] ;
	[ "[Day]" ; Left ( DayName ( ~date_time ) ; 3 ) ] ;
	[ "[day]" ; Lower ( Left ( DayName ( ~date_time ) ; 3 ) ) ] ;
	[ "[DAY]" ; Upper ( Left ( DayName ( ~date_time ) ; 3 ) ) ] ;
	[ "[DD]" ; Right ( "0" & Day ( ~date_time ) ; 2 ) ] ;
	[ "[D]" ; Day ( ~date_time ) ] ;
	[ "[MM]" ; Right ( "0" & Month ( ~date_time ) ; 2 ) ] ;
	[ "[M]" ; Month ( ~date_time ) ] ;
	[ "[Month]" ; MonthName ( ~date_time ) ] ;
	[ "[month]" ; Lower ( MonthName ( ~date_time ) ) ] ;
	[ "[MONTH]" ; Upper ( MonthName ( ~date_time ) ) ] ;
	[ "[Mon]" ; Left ( MonthName ( ~date_time ) ; 3 ) ] ;
	[ "[mon]" ; Lower ( Left ( MonthName ( ~date_time ) ; 3 ) ) ] ;
	[ "[MON]" ; Upper ( Left ( MonthName ( ~date_time ) ; 3 ) ) ] ;
	[ "[YYYY]" ; Year ( ~date_time ) ] ;
	[ "[YY]" ; Right ( Year ( ~date_time ) ; 2 ) ] 
)

)

Absolutely :100:

Nice! I've done the same, though I named them push, pull, pop, etc to keep in line with ancient Perl functions.

Very handy. Knowing your position in a queue is so important.

Supertrim ( text )

Speedily (and with no recursion) remove leading and trailing white space (including spacing, tabs, returns and line feeds) from a text string.

Some people would rename it to supertrim or @supertrim

Super useful.

2 Likes