I am trying to change the list column name. Here is my code, it isn't working. I added a content editor web part with this code:
<script type="text/javascript">
//js ref
</script>
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(initialize, "sp.js");
//Get our objects
function initialize(){
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle("News");
var field = list.get_fields().getByInternalNameOrTitle("testar");
context.load(field,"testar");
context.executeQueryAsync(Function.createDelegate(this,onListDataSucceeded),Function.createDelegate(this, onListDataFailed));
function onListDataSucceeded(sender, args){
field.set_title("NewName");
field.update();
};
function onListDataFailed(sender,args){
alert('List Data fetch failed. ' + args.get_message() + 'n' + args.get_stackTrace());
};
};
</script>
the error i get is:
List Data fetch failed. The field or the proeprty testar does not exist.nundefined