Skip to main content

Notifications

Power Apps - Power Apps Experimental Features
Unanswered

User Defined Types

(1) ShareShare
ReportReport
Posted on by
Welcome to User Defined Types!  This community forum post is a gathering place for questions and feedback on the feature.  Please let us know what you think and if you run into any problems.
 
Basic information can be found under "User Defined Types" in App object in Power Apps - Power Platform | Microsoft Learn
 
This is an experimental feature and we are continuing to make changes to it.  It is disabled by default and must be enabled in Settings > Updates > Experimental to use it.
 
Thank you for your help in creating high quality and useful UDTs!
  • TxH Profile Picture
    TxH 170 on at
    User Defined Types
    Hi @_follone,
    have you tried renaming the property This to any other value? This is a reserved word and may be the reason for the error message.
    Hope that helps.
  • _follone Profile Picture
    _follone 25 on at
    User Defined Types

    Hello everyone,

    I'm really enjoying using UDFs and UDTs, especially now that it's possible to place behavior functions in the formula bar. However, I'm encountering an error:

    I have the following record:
     

    {
        Last: {Year: "xx", Quarter: "xx"},
        This: {Year: "xx", Quarter: "xx"},
        First: {Year: "xx", Quarter: "xx"},
        Second: {Year: "xx", Quarter: "xx"},
        Third: {Year: "xx", Quarter: "xx"}
    }
    
    And I declared it as follows:
     
    tpQuarter := Type(
        {
            Year: Text,
            Quarter: Text
        }
    );
    
    tpNextQuarters := Type(
        {
            Last: tpQuarter,
            This: tpQuarter,
            First: tpQuarter,
            Second: tpQuarter,
            Third: tpQuarter
        }
    );
    

    The tpQuarter declaration doesn't return an error, but tpNextQuarters does:

    So, I moved the logic that was previously in an enhanced component property of type "Action" to the formula bar:

     

    udfGetNextQuarters(ParamCurrentYear:Text, ParamCurrentQuarter:Text):Void = 
    {
        // Calculate the next four quarters based on the parameters ParamCurrentYear and ParamCurrentQuarter
        With(
            {
                SelectedYear: ParamCurrentYear,
                SelectedQuarter: ParamCurrentQuarter
            },
            Set(voNextPeriod,
                {
                    Last: {
                        Year: "xx",
                        Quarter: "xx"
                    },
                    This: {
                        Year:       "xx", 
                        Quarter:    "xx"
                    },
                    First: {
                        Year:       "xx", 
                        Quarter:    "xx"
                    },
                    Second: {
                        Year:       "xx", 
                        Quarter:    "xx"
                    },
                    Third: {
                        Year:       "xx", 
                        Quarter:    "xx"
                    },
                    Fourth: {
                        Year:       "xx", 
                        Quarter:    "xx"
                    }
                }
            )
        )
    }
    ;
    
     

    However, I still get the same error:
     

    In other words, I can't add multiple properties to a record. I know that a temporary solution would be to create a table like this:


     

    tpQuarter := Type(
        {
            Name: Text,
            Year: Text,
            Quarter: Text
        }
    );
    
    tpNextQuarters := Type(
        [tpQuarter]
    );
    


    But the previous examples work both in an enhanced component property of type "Action" and in the "OnSelect" of a button. I just wanted to report this issue to you, as I believe it might be a bug.
  • TxH Profile Picture
    TxH 170 on at
    User Defined Types
    Here are my 2 cents about User Defined Functions:

    In September 2022, @GregLi announced Named Formulas in this blog post.
     
    As can be seen from the sample code of an early prototype shown there, the announcement included, among other things, the recursive call of User Defined Functions (see TotalReports() calling itself).
     
     
    Recursive function calls are great to search tree structures where the depth of the structure is not known beforehand (i.e. a Node has a Parent Node that can also have a Parent node...).
     
    With the last update, Behavior Functions have been made available, which is a big step in the right direction, but recursive function calls are still not supported.
    Currently this functionality can only be used with Property Type Actions (Enhanced component properties), but this component functionality does not support User Defined Types as parameters.
     

    It would be really great if the team could comment on whether this functionality will be implemented at a later date or whether it has been removed from the backlog, which I would very much regret.
     
  • arpost Profile Picture
    arpost 451 on at
    User Defined Types
    Looking forward to exploring this further. Out of curiosity (and it may be too early to ask this), are there any plans for this to be expanded such that it could support dynamic schema scenarios for cases where an API or a dataset may return something like JSON with a variable number of properties? Or will we have to predefine those types still?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard

Featured topics