Skip to content

Instantly share code, notes, and snippets.

@Zerg00s
Created December 20, 2018 03:40
Show Gist options
  • Save Zerg00s/ad42316c9b1ee9d7a99087b62f39751d to your computer and use it in GitHub Desktop.
Save Zerg00s/ad42316c9b1ee9d7a99087b62f39751d to your computer and use it in GitHub Desktop.
Get all internal field names using JavaScript
async function GetFields(listTitle){
let data = await fetch(`${_spPageContextInfo.siteServerRelativeUrl}/_api/web/lists/GetByTitle('Users')/Fields?$filter=Hidden%20eq%20false`,
{
headers: {"Accept":"application/json;odata=verbose"}
});
let fields = await data.json();
console.log(fields.d.results.map(field=>`${field.Title} | ${field.InternalName}\n\r`).join("") );
}
// pass the list name:
GetFields("Users")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment