web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Display 'content type'...
Power Apps
Answered

Display 'content type' column in PowerApps gallery

(0) ShareShare
ReportReport
Posted on by 29

I have a SharePoint list where we add records per the selection of content types from a column named "AssetType".

In a PowerApp Gallery display I want to display the specified content type (AssetType) for a particular record as text.  I tried the following:

 

text = fx: 
ThisItem.AssetType     (doesn't work)
ThisItem.AssetType.Value   (thinking a content type is like a choice column.  doesn't work)
ThisItem.'{ContentType}'   (doesn't work)
ThisItem([@'AssetInventory'].'{ContentType}')    (doesn't work)
Choices([@'AssetInventory'].'{ContentType}')   (doesn't work)

Is it possible to display a content type column as text in a PowerApp gallery?  If so, how??

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @heres2u 

    You can only get to the ID of the content type.  Use ThisItem.'Content type'.Id

    PowerApps doesn't support getting more information on them than that.  

    As far as I am aware, the only real way to identify them properly in the app is to then hard-write the Id's into your app to compare.

     

    So, for example, if you had a global variable in your app (perhaps set in the OnStart) like this:

    Set(glbContentTypes,
     Table(
     {Id: "0x0100DDE3Af4D553AAF322", Name:"Content Type 1:"},
     {Id: "0x0100DDE4D3Af553223AAF", Name:"Content Type 2:"}
     )
    )

    Then in your Gallery...

    LookUp(glbContentTypes, Id=ThisItem.'Content type'.Id, Name)

    This would give you what you are looking for.

     

    I hope this is helpful for you.

  • rsaikrishna Profile Picture
    3,703 on at

    @heres2u 

     

    It is weird issue. The ID is showing up fine but not the Name.

     

    Creating a collection with specific IDs and name (hardcoded in the app or read from a list) and referring it as datasource to show in the gallery is a work around.

     

    This bug exists from long time.

     

    Reference:

    https://powerusers.microsoft.com/t5/Building-Power-Apps/SharePoint-Content-Types-in-PowerApps-Form-A-Workaround/td-p/813257

     

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Powerapp-Formula-error-for-Content-type-Name-Invalid-Identifier/td-p/300115

     

    Regards

    Krishna Rachakonda

    If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @rsaikrishna 

    Yes, name has never returned anything for a content type.  Collection is overhead.  Just put the table in a variable and lookup as shown in the formula provided.

  • heres2u Profile Picture
    29 on at

    What I ended up doing to get the Id of each Content type from the Sharepoint list was to use:
    Text = fx    ThisItem.'Content type'.Id     in a Gallery Text Label  Since I had records in the Sharepoint list with various content types assigned, I could deduce which Content type Id went with each ContentName.

    Then, I put those Id's and ContentNames in a table as a global variable as advised, at the App level, onStart:

    Set(glbContentTypes,
    Table(
    {Id: "AA277863BE0330970200B342B61A6D37C749A9B41C5D52B7", ContentName:"Desktops"},
    {Id: "AA277863BE03309703006696FE7A12CB1E4D8F97F4CB1F417", ContentName:"Laptops"},
    {Id: "AA277863BE0330970400B2DB9313202AEF4E8AB05FD62C15A", ContentName:"Servers"}
    )
    )

    Then back in the Powerapp Gallery I can reference the Content type 'ContentName' as advised:
    Text = fx    LookUp(glbContentTypes, Id=ThisItem.'Content type'.Id, ContentName)


    However,  now I'm left wondering how to adjust my Gallery Search Filter to accommodate the 'ContentName' from that table set by the global variable?

    I have (where: Tech Assets is the Sharepoint list, and glbContentTypes is the global variable):

    SortByColumns(Filter([@'Tech Assets'],
    (TextSearchBox1.Text in Title)
    Or (TextSearchBox1.Text in 'ID Barcode')
    Or (TextSearchBox1.Text in 'Building Room')
    Or (TextSearchBox1.Text in 'Warranty Date')
    Or (TextSearchBox1.Text in glbContentTypes.ContentName)

    ), "Title", If(SortDescending1, Descending, Ascending))

    No errors, when adding "Or (TextSearchBox1.Text in glbContentTypes.ContentName)", but this added filter on my apps's variable's table's field's name doesn't seem to work.   

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @heres2u 

    You need to search the table variable and then compare the content type from the list.

    Ex:

    SortByColumns(
     Filter('Tech Assets',
     (TextSearchBox1.Text in Title & 'ID Barcode' & 'Building Room' & 'Warranty Date') ||
     'Content type'.Id in Filter(glbContentTypes, TextSearchBox1.Text in ContentName).Id
     ), 
     "Title", 
     If(SortDescending1, Descending, Ascending)
    )

    No need to repeat the "TextSearchBox1.Text" in statement over and over...just concatenate the columns with the data you want into one string and throw the in operator at that.

    In the second part of the criteria, it is comparing the record content type Id to be anything found in the Filter of the content type table variable.

  • RRFreeman Profile Picture
    19 on at

    This is much easier to accomplish if using a SharePointIntegration SharePointForm.

    Simply add and unlock the Content Type DataCard and select the Combo Box control. 
    Under Properties / Fields select Edit.

    Change both the Primary text and SearchField to Name from Id.

     

    RobertRFreeman_0-1705711057615.png

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard