Skip to main content

Notifications

Community site session details

Community site session details

Session Id : N2FDu16F8YOMLzFmOIjMfR
Power Apps - Building Power Apps
Answered

Display fields on NewForm based on content type

Like (3) ShareShare
ReportReport
Posted on 24 Feb 2025 18:59:37 by 44
Hello,
 
I have a SharePoint list which contains two content types: ContentTypeA and ContentTypeB.
 
ContentTypeA has two fields: Title and Type
 
ContentTypeB has one field: Title
 
In OOTB SharePoint, when a new item is added, in the EditForm and DisplayForm, the content type field displays.  I want to hide the content type field.  As a result, I've used a custom form created in PowerApps to hide the content type field.
 
On new item, if I click ContentTypeA, I should see two fields. If I click ContentTypeB, I should see one field. However, when I click ContentTypeB, it displays the fields of ContentTypeA because ContentTypeA is the default content type.
 
In PowerApps, for the Type field and in the Visible property, I've added the following formula: If(ThisItem.'Content type'.Name="ContentTypeA ",true,false).  The results of this formula is on NewForm, the Type field does not display when clicking ContentTypeA or ContentTypeB. 
 
I need the PowerApps form to behave similarly to OOTB SharePoint. In that, when I click ContentTypeA, I see the intended fields. Same if I click ContentTypeB.
 
Is this possible in PowerApps?
 
BTW, I do not have this issue when using this formula when on the EditForm or DisplayForm.  Based on the content type, the correct fields display on these forms.
 
 
  • itchel123 Profile Picture
    44 on 26 Feb 2025 at 17:54:02
    Display fields on NewForm based on content type
     
    I've followed your steps but added additional functionality. 
     
    I have three screens:
    1. MainScreen
    2. Screen1
    3. Screen2
    Main screen has a form that includes the dropdown control. In the dropdown, in the OnSelect, I've added the following:
     
    If(DataCardValue_MyDD.Selected.Value="Type A", Navigate(Screen1), DataCardValue_MyDD.Selected.Value="Type B", Navigate(Screen2))
     
    This works, however, if navigated to Screen1, the form includes data from previous entries.  This is the same behavior when navigated to Screen2. Also, if I click the New button in the SharePoint list, it doesn't load the MainScreen but instead the Screen1 or Screen2. If I refresh SharePoint, and click New, it loads the MainScreen.
     
    To fix both issues, I've tried the following formula on SharePointIntegration in PowerApps. I've added this code to the OnNew event.
     
    NewForm(MainForm); Set(varFormMode,FormMode.New); Navigate(MainScreen,ScreenTransition.None); ResetForm(MainForm); ResetForm(Form1); ResetForm(Form2);
     
    This doesn't fix the issues. Is there a way to resolve both issues? Also, do I need to add any scripts to the OnEdit or OnView events to ensure that the item that's selected in SharePoint, loads the correct form?  So, on the MainScreen, I select dropdown value, "Type A", it navigates to Screen1. I fill out Form1 and Save. When I click the saved item, I expect to see fields listed in Screen1 and not Screen2.
     
     
    EDIT:
    The ResetForm function works as long as Form1 and Form2, Default Mode is set to New.  By default, it's set to Edit.  I assume the ResetForm function doesn't work well if the form's default mode is Edit or View. 
     
    NewForm(MainForm); Set(varFormMode,FormMode.New); Navigate(MainScreen,ScreenTransition.None); ResetForm(MainForm); ResetForm(Form1); ResetForm(Form2);
     
    The issue that I'm having now has to do with the OnEdit and OnView events.  Both are set like this:  ViewForm(MainForm). So, when I select a saved entry, it displays the main screen and not the screen based on which drop down item I've selected. 
  • Verified answer
    EW-20120954-0 Profile Picture
    27 on 25 Feb 2025 at 10:03:17
    Display fields on NewForm based on content type
    Hi! it is definitly possible to achieve, I have summarized it below.

    If this worked for you please accept this answer as a accepted solution!
     

    In PowerApps, you can dynamically show or hide fields based on the selection of "Type A" or "Type B" using the Visible property of controls. Here's how to do it:

    Steps:

    1. Add a Dropdown for Selection:

      • Insert a Dropdown control (ddTypeSelection).
      • Set its Items property to:  ["Type A", "Type B"]
    2. Add Input Fields:

      • Add text input controls or other controls needed for both Type A and Type B.
      • Example:
        • txtFieldForA → Field specific to Type A
        • txtFieldForB → Field specific to Type B
    3. Set Visibility Based on Selection:

      • For fields related to Type A (txtFieldForA), set the Visible property to:
         
        ddTypeSelection.Selected.Value = "Type A"
        		
        
        		
        		
      • For fields related to Type B (txtFieldForB), set the Visible property to:
         
         
        ddTypeSelection.Selected.Value = "Type B"

    Optional Enhancements:

    • If you have multiple fields for each type, group them inside Containers to simplify visibility control.
    • Use Switch() instead of multiple If conditions for better maintainability.
  • mmbr1606 Profile Picture
    12,260 Super User 2025 Season 1 on 25 Feb 2025 at 09:41:50
    Display fields on NewForm based on content type
    hey
     
     
    where do you choose if it is content type a or b?
     
    thanks in advance,
     
     
    cheers

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 85 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 54

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 42 Super User 2025 Season 1

Overall leaderboard
Loading started