I have a list. I want to retrieve the fields to see how many column are there in my list.

For example, my list name is TestList, I have created 5 columns of different datatypes. I want to retrieve those 5 fields plus 5 default columns like Id, Modified, Modified By, Created and Created By.

This code gives me lots of fields where I am tired to find my created field (column). Is there any simple query that will return my created 5 fields plus default column fields (mentioned above)?

let myweb = new 
myweb.lists.getByTitle(listTitle).fields.get().then((results: any) => {                
    if(results.length > 0) {

this gives me a lot of fields

Help is appreciated.

3 Answers 3


Thanks for your pointer. I think I found my solution on exactly what I want. Here is the code for my requirement. I shared it so that everybody can be benefited.

        let myweb = new pnp.Web(encodeURI(siteUrl));
        const list = myweb.lists.getByTitle(listTitle);
        const includeFields = ['ID', 'Title', 'Modified', 'Modified By', 'Created', 'Created By'];
        const filter = `CanBeDeleted eq true or (${includeFields.map(field => `Title eq '${field}'`).join(' or ')})`;
        list.fields.select('Id', 'Title', 'InternalName', 'EntityPropertyName', 'CanBeDeleted', 'Hidden', 'ReadOnlyField').
            filter(filter).get().then(fields => {
                if (fields.length > 0) {

            }).catch(e => {

Here is the output I formatted based on the query:

ID: fa564e0f-0c70-4ab9-b863-0177e6ddd247
Title: Title
Internal Name: Title

Title: FirstName // This is my custom column
Internal Name: FirstName

Title: ID
Internal Name: ID

Title: Modified
Internal Name: Modified

Title: Created
Internal Name: Created

Title: Created By
Internal Name: Author

Title: Modified By
Internal Name: Editor

Title: Modified
Internal Name: Last_x0020_Modified

Title: Created
Internal Name: Created_x0020_Date

One of the good pointers I found is https://pnp.github.io/pnpjs/sp/docs/fields/


To get all fields except hidden and readonly fields, try below code:

<script type="text/javascript" src="/siteassets/scripts/fetch.js"></script> 
<script type="text/javascript" src="/siteassets/scripts/es6-promise.js"></script> 
<script type="text/javascript" src="/siteassets/scripts/pnp.min.js"></script>
<div id="sample"></div>
<script type="text/javascript">
//fields property returns all fields from the retrieved list
//then( ) runs on success
//catch( ) runs on failure
$pnp.sp.web.lists.getByTitle("TelePhones Growth").fields.filter("ReadOnlyField eq false and Hidden eq false").get().then(function(result) {
    var fieldInfo = "";
    for (var i = 0; i < result.length; i++) {
        fieldInfo += "Title: " + result[i].Title + "<br/>";
        fieldInfo += "Name:" + result[i].InternalName + "<br/>";
        fieldInfo += "ID:" + result[i].Id + "<br/><br/>";
    document.getElementById("sample").innerHTML = fieldInfo;
}).catch(function(err) {


  1. Retrieve visible fields from SharePoint List using PnP JavaScript Library.

You can also get fields by its ID, Title, or internal name, like below:

let web = pnp.sp.web;

// you can also get individual fields using getById, getByTitle, or getByInternalNameOrTitle
web.fields.getById("dee9c205-2537-44d6-94e2-7c957e6ebe6e").get().then(f => {
web.fields.getByTitle("MyField4").get().then(f => {
web.fields.getByInternalNameOrTitle("MyField4").get().then(f => {


  1. Working With: Fields.

You can also get the internal name of your columns from SharePoint UI by following this article: How to find the Internal name of columns in SharePoint Online?

  • Thanks @Ganesh sanap for the pointer, but I need more detailed. I am trying on it. Feb 18, 2019 at 12:24
  • Actually your code didn't solve my exact requirement, I had spent a night to find and I already shared. Feb 18, 2019 at 12:48

Use below query, you should be able to get just the custom fields you have created.

let myweb = new pnp.Web(encodeURI(siteUrl)); 
myweb.lists.getByTitle(listTitle).fields.filter("Hidden eq false and ReadOnlyField eq false").get().then((results: any) => 
   if(results.length > 0) { 

This query will use the filter attribute to exclude the hidden and readonly fields and retains only the required ones.

Hope this is helpful.

  • Actually I looked for a combination of Hidden, ReadOnly and Custom fields. Feb 20, 2019 at 6:08
  • Sure no problem, Glad to know that you are able to solve the issue you were facing. Feb 20, 2019 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.