This topic has not yet been rated - Rate this topic

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

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
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" />