Recently I already mentioned Named Formulas and User Defined Functions in my posts. Today I’m looking at the in preview User Defined Types.
Named Formulas vs User Defined Functions vs User Defined Types
Table of Contents
Named Formulas can be used where you would traditionally use collections with filters. You take a datasource and you run predefined expressions on your data. This could be the data that is presented in in a gallery and you have all your filter options specified in your Named Formula.
The important thing to remember is that Named Formulas are always up to date when you need them (well, that is almost always up to date).
User Defined Functions are fairly similar to Named Formulas. The big difference is that you can pass parameters into the User Defined Function to generate a result that is of a predefined data type. Now up to recently you could only use simple data types (number, text, date etc).
Microsoft recently released User Defined Types. User Defined Types can handle the output from the ParseJSON function to make the conversion of that Untyped Object to a typed object easier.
However , User Defined Types can also help with User Defined functions returning data in a specified data structure.
An example is shown below:

Yes, User Defined Types are just like Named Formulas and User Defined Functions stuffed into the Formulas property.
I really wish that there was a more modular way to organise my Named Formulas instead it looks like we are receiving even more code in the already overcrowded Formulas property.
Splitting the three UDTs, UDFs and NFs into separate properties would have been nice. Having some kind of grouping into each of these would have been even better. Or maybe classes like we have seen in C# for many years.
User Defined Types
This brings back memories from the time I programmed in Turbo Pascal.
With User Defined Types you can specify types of data in data structures. So for example, we can create our own data type that separates the Day, Month and Year.
ftDate := Type({
Day: Number,
Month: Number,
Year: Number
}); If you wanted to you could even nest these data structures.
ftRegistration := Type({
Name: Text,
RegDate: ftDate
}); Using User Defined Functions
Now in your User Defined Functions you can use the data type as specified earlier as follows:
nfSplitDate(MyDate:DateTime):ftDate = {
Day: Day(MyDate),
Month: Month(MyDate),
Year: Year(MyDate)
}; ParseJSON and User Defined Types
When we use ParseJSON with User Defined Types we could use the following example:
AsType(ParseJSON("{""Day"": 16, ""Month"": 12, ""Year"": 2024}") , ftDate) The AsType function now gives use the data in the same structure as defined by the ftData User Defined Type.

FAQs
What are Uder Defined Functions?
User Defined functions are data structures in Power Apps that specify the structure of a record. They can typically be used to convert an untyped record into a typed record.
Discover more from SharePains
Subscribe to get the latest posts sent to your email.