Getting the available Record Types in the org versus the Record Types a User is allowed might be different. To help this in Flow, a new Apex Action, Get Available Record Types, was added in the Winter ’21 release. This Apex Action will get the available Record Types that the User has access to, including the default record type, to help ensure your User is creating Records using Record Types they are allowed to use, with ease. Additionally, there is a Lightning Component, Record Type Picklist, that will allow you to easily show the Record Types to User and use the selected Record Type later in the Flow.

First, take a look at the Apex Action, Get Available Record Types. In the example below, we are looking up the available Account Record Types for the User. To do this, you first enter the Object API Name, in this instance, Account. You will need to click the box, Manually assign variables (advanced) so that you can set your variables appropriately. Then, you need to have a text Variable to store the default Record Type Id for the User. Finally, you need to have a collection Variable, type of Object, where the Object is Record Type, to store the full list of Record Types available for the User. See second screenshot for an example.

After you run the Get Available Record Types Apex Action, you then can use the Record Type Picklist Lightning Component in a screen to allow your Users to select the record type they would like to use. As you can see in the example below, you use the default record type id as the Default Value / Selected Value and you use the Record Type collection variable as the Picklist Values. Additionally, it is recommended to click the Manually Assign Variables (Advanced) and use a text variable to store the Id of the Record Type that the User selected in the Default Value / Selected Value. You can then use this text variable as the Record Type Id in any record that you’re creating.

9 comments

  1. Hi Rich,
    First, thanks a lot for this great component. It works like a charm for my user (admin).

    In our use case, we need to retrieve the developer name of the selected record type in order to check for duplicate at a later stage in the flow.

    Unfortunately i’m only able to save the record type id in your Record Type Picklist component and the Get Record returns ‘failed to find records’ when the flow is ran as a non-admin user:

    Get_info_of_selected_Record_Type
    Find all RecordType records where:
    Id Equals {!SelectedRecordTypeId} (012000000000000AAA)
    Store the values of these fields in Get_info_of_selected_Record_Type: Id, DeveloperName, Name
    Result
    Failed to find records

    Would you have any workaround for to achieve this?

    Thanks again and best regards,
    Xavier

    1. Hi Xavier,

      You’re welcome, I’m glad you find it nice!

      The first thing to check is that the User has access to Record Types. I believe that the Id that you found is the Master Record Type Id, meaning that the User has not been assigned Record Types. I also believe that might be why you are getting the error. Either you should be getting record types back, which may mean that if the User does have access to record types, they might need access to the Apex Class, ecflc.flowUserRecordType, or you need to check first to see if they are using the master Record Type, and if they are, then do something else instead of search for the Record Type developer name.

      Let me know how it goes!

      Rich

      1. Hi Rich,

        Thanks for your answer, it helped me finding out what I was doing wrong. Basically, in the Record Type Picklist component, I had to leave Default Value / Selected Value empty and only keep the record collection variable in Picklist Values.

        It’s now working fine for standard user.

        I’m not 100% sure why, but for me the selected value would always come as the master record type in the debug. (PS: our users don’t have access to RT through Profiles, only through Permission Set)

        Thanks again
        Best regards
        Xavier

  2. Hello, where does this functionality exist? I cannot find this flow action. Could you please help ?

      1. Hi Rich and thank you for your reply! I am creating a Screen flow, however i cannot find the action in my Sandbox. 🙁 Do i need to install a package?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: