sharepoint-onlinespfxpnp-js

How to find the column type in SPFx?


Does anyone know the best way in SPFx to find the type of a column in a list or document library? I mean if it's a "Single line of text" "Date and Time" "Choice" "Hyperlink or Picture" etc Thanks P


Solution

  • It's easy to do this using PnPjs: https://pnp.github.io/pnpjs/sp/fields/

    ex:

      const fieldInfo = await sp.web.lists.getByTitle("List1").fields.getByInternalNameOrTitle("FieldName")();
      console.log(fieldInfo .TypeDisplayName)