<button onclick='GetFieldDetails()'>Get Details</button>
<script type="text/javascript">
function GetFieldDetails()
{
var listname = "Employee";
var context = SP.ClientContext.get_current();
this.web = context.get_web();
context.load(this.web);
this.list = web.get_lists().getByTitle(listname);
context.load(this.list);
this.fields = this.list.get_fields();
context.load(this.fields);
context.executeQueryAsync(Function.createDelegate(this, this.getListInfoSuccess), Function.createDelegate(this, this.getListInfoFail));
}
function getListInfoSuccess(sender, args)
{
var fieldEnumerator = this.fields.getEnumerator();
var results="";
while (fieldEnumerator.moveNext()) {
var oField = fieldEnumerator.get_current();
if (!oField.get_hidden())
results+= oField.get_title()
+ " - " + oField.get_internalName()
+ " - " + oField.get_hidden()
+ "\n";
}
alert(results);
}
function getListInfoFail(sender, args)
{
alert('Something failed. Error:'+args.get_message());
}
</script>
No comments:
Post a Comment