SP.FieldLookupValue.lookupId Property
SharePoint 2010
Gets or sets the identifier (ID) of the list item that this instance of the lookup field is referring to.
var value = SP.FieldLookupValue.get_lookupId(); SP.FieldLookupValue.set_lookupId(value);
Type: Int32
Example
<script language="ecmascript" type="text/ecmascript">
var listItem;
var list;
var clientContext;
function getLookUp() {
this.clientContext = SP.ClientContext.get_current();
if (this.clientContext != undefined && clientContext != null) {
var webSite = clientContext.get_web();
this.list = webSite.get_lists().getByTitle("Custom");
this.listItem = list.getItemById(5);
clientContext.load(this.listItem);
this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed));
}
}
function OnLoadSuccess(sender, args) {
var lookup = this.listItem.get_item("LookupSingleValue");
alert("Lookup Id: " + lookup.get_lookupId() + "\n Lookup Value: " + lookup.get_lookupValue());
}
function OnLoadFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}</script>
<input id="btnGetLookUp" onclick="getLookUp()" type="button" value="Get Look Up" />
- 1/27/2012
- anavijai