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.

18 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?

  3. Hello, I have 2 questions.

    1. Is it possible to filter the record types to show specific ones?
    2. After you select a record type, can the page layout related to the selected record type be displayed in a screen flow?

    Thank you!

  4. Love the component! However, it shows inactive recordtypes as well that are available. Do you know a fix for this?

    1. Hi Ben,

      Are you using the Get Available Record Types action to populate the Record Type Picklist? The action is checking for active record types in addition to record types allowed for the user, ensuring that they only see the one that they are allowed to use.

  5. Hi
    This is a great solution!! Thank you!
    Just one question, The record type that the APEX looking for, is only the record type on the profile? or also on PS/PSG, Sharing Rule and more..?

      1. Thank you so much Rich!
        Last question, there is a way to translate the picklist on the screen flow?

    1. Yes, but not all users will have access to create all record types, and it will not list the default record type for the user. If that isn’t a concern, then the record type picklist lookup in flow works, but if users have restricted picklist types or different default record types, that starts to not work, which is where this comes into play.

Leave a Reply

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

Discover more from Englhard Consulting LLC

Subscribe now to keep reading and get access to the full archive.

Continue reading