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

**URL:** <https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091>\
**Category:** Lounge (Discussions)\
**Tags:** custom-function\
**Created:** [September 15, 2022, 5:41am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091 "2022-09-15T05:41:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 15, 2022, 5:41am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/1 "2022-09-15T05:41:48Z")

</div>

I use a lot of custom functions but there is one that I always include in every file. I have been using it for so long that I expect it to be in new files that don't have any custom functions. I think that I should donate it to Claris and ask them to include it in the next version update.

The function is really simple. It checks to see whether the current layout context is the one you want it to be. You pass it a field reference, and it returns true if the field occurs in the current layout table. I've [talked about it a while ago](https://the.fmsoup.org/t/best-way-to-check-filemaker-context/1500/3), so you can copy it from that thread into your own solutions if you like.

I wonder what custom functions you've got that you think should be a FileMaker built-in?

---

<div class="post-metadata">

**Author:** ![harvest](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/harvest/32/231_2.png) [@harvest](https://the.fmsoup.org/u/harvest)\
**Post date:** [September 15, 2022, 7:32am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/2 "2022-09-15T07:32:59Z")

</div>

the first thing coming to my mind is a number-to-text function with all the features you would expect and that already can be used when tweaking it for the interface in the inspector

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 15, 2022, 8:20am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/3 "2022-09-15T08:20:32Z")

</div>

That sounds great, string formatting in text objects is tedious.

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [September 15, 2022, 8:33am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/4 "2022-09-15T08:33:40Z")

</div>

positionValue by Josh Ormond. Nearly no app where I don’t use it!

> **[FileMaker Custom Function: positionValue ( string ; searchString ; start ;...](https://www.briandunning.com/cf/2320)**
>
> Return the value's position in a list, including a partial match.

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [September 15, 2022, 8:42am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/5 "2022-09-15T08:42:33Z")

</div>

And even more important: Regular expressions!

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 15, 2022, 8:54am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/6 "2022-09-15T08:54:30Z")

</div>

That's a great method. Definitely worth having as a CF.

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [September 15, 2022, 1:11pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/7 "2022-09-15T13:11:13Z")

</div>

I first thought I had a complex answer, then realized I have a simple answer.

I have many essential custom functions. The function that reduces my sweat the most these days is a 135-line monster that validates data. I give it a JSON structure that contains the data to validate and a JSON structure that contains the validation specification. It indicates whether the data conforms to the specification and, if not, the reason of the first failed validation.

Data, here, doesn't just mean JSON values. Both keys and values are validated.

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [September 15, 2022, 3:46pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/8 "2022-09-15T15:46:34Z")

</div>

I find myself routinely wishing that there were a FMP native version of [Bruce Robertson's "AntiFilterValues" function](https://www.briandunning.com/cf/926).

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 15, 2022, 6:43pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/9 "2022-09-15T18:43:42Z")

</div>

Yes! JSON validation is so important. Does the JSONGetElementType function match any of that functionality?

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [September 15, 2022, 7:12pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/10 "2022-09-15T19:12:26Z")

</div>

> [@Malcolm](#):
>
> Does the JSONGetElementType function match any of that functionality?

No! My custom function doesn't validate the correctness of JSON structures. It validates the keys and the values within the JSON function against a specification. Key validation is limited to the existence of a key or not within a JSON structure. Value validation can check for any of the following: integer; non-empty; min length; max length; min value; max value; member of list; member of value list; negative; non list; non negative; positive.

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [September 15, 2022, 7:32pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/11 "2022-09-15T19:32:14Z")

</div>

> [@bdbd](#):
>
> It validates the keys and the values within the JSON function against a specification. Key validation is limited to the existence of a key or not within a JSON structure. Value validation can check for any of the following: integer; non-empty; min length; max length; min value; max value; member of list; member of value list; negative; non list; non negative; positive.

Sounds like a fantastic function to have in one's toolkit.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 15, 2022, 8:19pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/12 "2022-09-15T20:19:49Z")

</div>

Bruce's function is great. It does what I expect filters to do - which is to remove things.

---

<div class="post-metadata">

**Author:** ![taylorsharpe](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/taylorsharpe/32/2933_2.png) [@taylorsharpe](https://the.fmsoup.org/u/taylorsharpe)\
**Post date:** [September 16, 2022, 5:51pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/13 "2022-09-16T17:51:19Z")

</div>

I have one that takes a list array or JSON and makes it into Google Maps HTML. I think we all have various Date/Timestamp ones for conversions. I also have a History one that tracks record changes in a JSON format. I have one that formats currency into properly formatted text string or even spells out the wording of the currency amount. And I have one that gathers all of the stored values in a record and makes them into a JSON variable (useful when changing context to retain previous record data). Most of these are in the various FileMaker templates I share for free at [https://tms.us/FM](https://tms.us/FM)

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 16, 2022, 8:33pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/14 "2022-09-16T20:33:24Z")

</div>

All of those sound great. I'm going to have to check them out. 😀 And thanks for sharing.

---

<div class="post-metadata">

**Author:** ![Bobino](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bobino/32/194_2.png) [@Bobino](https://the.fmsoup.org/u/Bobino)\
**Post date:** [September 17, 2022, 7:08pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/15 "2022-09-17T19:08:25Z")

</div>

I rarely create custom functions. More often, I will modify existing ones or combine some together.

One such alteration combines a custom function from @steve_ssh and another one from Kevin Frank to merge 2 JSON objects (not a shallow merge where only the first level get merged, but rather merging all the keys).

It also sounds to me like appending to a JSON array should be something the platform offers natively.

I'm sure we all lost some sleep over trying to establish the type of a given piece of data (is it a number, is it some text, is it a date, ...). It would be so much better if Claris was surfacing data types we can read for things we are handling.

Finally, there is a number of functions (specially get functions) I hope would get renamed for readability reasons. A bunch of them following a "object.attribute (optional param)" pattern where something like `Window.Width (optionalWindowName)` would replace get(WindowWith), target the current window by default, but let us target another window if specified.

That's it, I think. So, I guess I cheated by not answering your original question directly, I hope can still inspire people. I am curious to see what others will mention.

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [September 18, 2022, 1:28am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/16 "2022-09-18T01:28:53Z")

</div>

> [@Bobino](#):
>
> It also sounds to me like appending to a JSON array should be something the platform offers natively.

+1 . Great point.

---

<div class="post-metadata">

**Author:** ![cheesus](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/cheesus/32/182_2.png) [@cheesus](https://the.fmsoup.org/u/cheesus)\
**Post date:** [September 18, 2022, 10:58am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/17 "2022-09-18T10:58:53Z")

</div>

I love custom functions, that make FileMaker Code more human readable, for example:

**IsWindows** ➔ get(systemplatform)=-2  
**IsMac** ➔ get(systemPlatform) = 1  
**IsClient** ➔ PatternCount (get(FilePath); "fmnet") =1  
**IsRuntime** ➔ PatternCount ( Get ( ProgramVersion ) ; "Runtime" ) =1

Absolutely indispensable are 2 CFs (GFN and GTN) that get  
a.) the name of a field without the relationship,  
b.) the name of a field's table  
so I can use it in SQL Statements in order to not break the code when the field gets renamed in the future.

---

<div class="post-metadata">

**Author:** ![LucThomaere](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/lucthomaere/32/3108_2.png) [@LucThomaere](https://the.fmsoup.org/u/LucThomaere)\
**Post date:** [September 21, 2022, 9:54am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/18 "2022-09-21T09:54:33Z")

</div>

I use custom functions a lot.  
Sometimes they are quite simple but they make calculations more readable and easier to understand afterwards.  
For example to work with value lists:  
**fValueAddBottom ( ValueList ; value )**  
**fValueAddTop ( ValueList ; value )**  
**fValueIndex ( ValueList ; value )** gives the index in the list of a certain value (not partially)  
**fValueInList ( ValueList ; value )** gives True when the value is found in the list (not partially)  
**fValueRemove ( ValueList ; value )**  
**fValueListRemove ( ValueList ; ListToRemove )** removes a list of values from another list  
**fValueToggle ( ValueList ; Value)** will remove a value if it already exists, or add it if it does not yet exist in the list

But the custom function I use almost always is a custom function to transfer multiple named parameters to scripts  
If the parameter string is for example "Art\_ID==" & $Art\_ID & "|Method==Copy|Save?==0"  
**fGetScriptParam ("Method")** gives as a result "Copy"  
The order of the parameters is not important and it is not necessary to send all parameters.  
If a parameter does not exist, the result = "?"

---

<div class="post-metadata">

**Author:** ![LucThomaere](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/lucthomaere/32/3108_2.png) [@LucThomaere](https://the.fmsoup.org/u/LucThomaere)\
**Post date:** [September 21, 2022, 9:59am UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/19 "2022-09-21T09:59:32Z")

</div>

> [@cheesus](#):
>
> a.) the name of a field without the relationship,  
> b.) the name of a field's table

That is very much true!  
I also have **fTableName** and **fFieldName** and use them also to build SQL commands without having fear it breaks up when a field name has changed

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [September 21, 2022, 1:59pm UTC](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/20 "2022-09-21T13:59:12Z")

</div>

Similar to @LucThomaere, I use a custom function to transfer parameters to script. The one I use creates a variable for each top-level key of a JSON structure. While awfully handy and in use in just about all my scripts with parameters, I chose the validation custom function instead as my top choice because it is used just about as often and saves me a lot more scripting time.

[Next page](https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091.md?page=2)
