Forum Discussion

Tarundeep's avatar
Tarundeep
Copper Contributor
Nov 30, 2018

Can I fetch ContentType as one of the selected fields in pnp SPFX Caml query

User will provide a list of URL's from Site pages, then I need to know the ContentType of each Site Page provided by the user. Is this possible, I am trying to do something as below but it's not showing the ContentType 

 

<ViewFields>
  <FieldRef Name='Title' />
  <FieldRef Name='ImageLogo' />
  <FieldRef Name='ContentType'/>
</ViewFields>

3 Replies

  • Alexseliv's avatar
    Alexseliv
    Copper Contributor
    To be able to use item.ContentType.Name or comparison item.ContentType.Name == "Some contentype", ViewFields should contain:
    <FieldRef Name='ContentTypeId' />
    Thanks to this blog:
    https://gp23.com.au/2017/03/28/csom-contenttype-and-caml-queries/
  • Are the other fields returning correctly, or is the entire query not working?

    • Tarundeep's avatar
      Tarundeep
      Copper Contributor

      Hi Thomas,

       

      Other fields are showing up perfectly. It's only with the Content Type. :-( 

Resources