Created
July 29, 2016 19:08
-
-
Save IAMIronmanSam/e4f83c2774d4c44e4e20904a54111ea8 to your computer and use it in GitHub Desktop.
Get field types & field name from list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetFieldsForList(Site, ListName) | |
{ | |
var ctx = new SP.ClientContext(Site); | |
var list = ctx.get_web().get_lists().getByTitle(ListName); | |
this.fields = list.get_fields(); | |
ctx.load(fields, 'Include(Title,InternalName,FieldTypeKind)'); | |
ctx.executeQueryAsync(Function.createDelegate(this, this.Success), Function.createDelegate(this, this.Failure)); | |
} | |
function Success() | |
{ | |
var _fields = ''; | |
var lEnum = fields.getEnumerator(); | |
while(lEnum.moveNext()) | |
{ | |
_fields += lEnum.get_current().get_title() + " - " + lEnum.get_current().get_internalName() + " - "+lEnum.get_current().get_fieldTypeKind()+";"; | |
} | |
console.log(_fields); | |
} | |
function Failure(sender, args) | |
{ | |
console.log("Failed" + args.get_message()); | |
} | |
GetFieldsForList('https://mydomain.sharepoint.com/sites/mysite/','profile') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment