I try to retrieve the content of a lookup field in a sharepoint 2010 list. (myList) I do this by using sharepoint designer and a javascript.js file The java script works for most columns in my script.
But not foor lookup columns.
My column Lookup column is named Device for lookup columns values it results:
[object Object]
including the brackets [ ], i'd like to know how to expand it to show the list content.
Here is my code to retrieve list data
<script type="text/javascript">
function ViewItem() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('myList');
var query = SP.CamlQuery.createAllItemsQuery();
allItems = list.getItems(query);
context.load(allItems, 'Include(Title,Device)');
context.executeQueryAsync(Function.createDelegate(this, this.success),Function.createDelegate(this, this.failed));
}
function success() {
var TextFiled = "";
var ListEnumerator = this.allItems.getEnumerator();
while(ListEnumerator.moveNext())
{
var currentItem = ListEnumerator.get_current();
TextFiled += currentItem.get_item('Title') + '->'
TextFiled += String(currentItem.get_item('Device')) + '<-'
TextFiled += + '\n';
}
alert(TextFiled);
}
function failed(sender, args) {
alert("failed. Message:" + args.get_message());
}</script><a onclick="Javascript:ViewItem();" href="#">View my Items</a>
`