Sunday 4 September 2011

Get Site columns ecmascript/Javascript client object model sharepoint 2010


var context = new SP.ClientContext.get_current();

var web = context.get_web();

//Get all fields in site collection
FieldCollection collFields = web.AvailableFields;

currentcontext.load(this.collFields);

currentcontext.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess),
Function.createDelegate(this, this.ExecuteOnFailure));
}

function ExecuteOnSuccess(sender, args)
{
var subsites = '';

for(int i=0; i {
if(collFields[0].Title == "siteColumnName"){
alert("Got the Site col");
}
}

}
function ExecuteOnFailure(sender, args) {
alert("error");
}

Ads by Google

1 comment:

  1. good post - suggested edits: no need for subsites var & would be helpful to include manipulating/updating the field!

    ReplyDelete