The following code will get the list of all the fields in the SharePoint List, however what I m interest in is if a particular field exists or not.
function retrieveFieldsOfListView(listTitle,viewName){
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle(listTitle);
var listFields = list.get_fields();
context.load(listFields);
context.executeQueryAsync(printFieldNames,onError);
function printFieldNames() {
var e = listFields.getEnumerator();
//debugger;
while (e.moveNext()) {
var field = e.get_current();
console.log(field.get_title());
}
}
function onError(sender,args)
{
console.log(args.get_message());
}
}
Please note, I don't have a list view with this field in it.

0 commentaires:
Enregistrer un commentaire