Copy and paste the following script.<script language="ecmascript" type="text/ecmascript">
var fieldCollection;
var field;
var list;
function fieldDefaultValue() {
var clientContext = SP.ClientContext.get_current();
if (clientContext != undefined && clientContext != null) {
var webSite = clientContext.get_web();
var fieldCollection;
var field;
var list;
function fieldDefaultValue() {
var clientContext = SP.ClientContext.get_current();
if (clientContext != undefined && clientContext != null) {
var webSite = clientContext.get_web();
this.list = webSite.get_lists().getByTitle("List Request");
this.fieldCollection = list.get_fields();
this.field = fieldCollection.getByTitle("Description");
this.field.set_defaultValue("Default"); this.field.update(); clientContext.load(this.field);
clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess),
Function.createDelegate(this, this.OnLoadFailed));
}
}
function OnLoadSuccess(sender, args) {
alert(this.field.get_defaultValue()); }
function OnLoadFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script> <input id="btnFieldDefaultValue" onclick="fieldDefaultValue()" type="button" value="Field Default Value" />
this.fieldCollection = list.get_fields();
this.field = fieldCollection.getByTitle("Description");
this.field.set_defaultValue("Default"); this.field.update(); clientContext.load(this.field);
clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess),
Function.createDelegate(this, this.OnLoadFailed));
}
}
function OnLoadSuccess(sender, args) {
alert(this.field.get_defaultValue()); }
function OnLoadFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script> <input id="btnFieldDefaultValue" onclick="fieldDefaultValue()" type="button" value="Field Default Value" />
its is good blog,,
ReplyDelete