I have a custom page like this :
These are my links (refresh once a day. Last refresh time : **XXXXX** )
link1
link2
link3
And I have a custom list.
I want to add "last modified time" or "modified X mins ago" instead of "XXXXX" of the custom list in my page. Is that possible ? Might be easy for advanced dev, but I can't find what to googled.
I found this and this. So I tried to add JS via embedded code in my page :
<script language='javascript' type='text/javascript'>
var siteUrl = "http://mysite/mysubsite";
var context = new SP.ClientContext(siteUrl);
var web = context.get_web();
var list = web.get_lists().getByTitle('MyListName');
var value = SP.List.get_lastItemModifiedDate();
write(value);
</script>
But this doesn't return anything. As I'm not a developer, I really don't understand what's going on, Any ideas?
I have to say that I also tried this (I've customized variable as needed) without success :
function ReadListItem() {
siteUrl = "my site Url";
var listTitle = "NewsList";
//Get the current client context
var context = new SP.ClientContext(siteUrl);
var newsList = context.get_web().get_lists().getByTitle(listTitle);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name=\'Modified\' Ascending="FALSE"/></OrderBy><RowLimit>1</RowLimit></Query></View>";')
this.listItems = newsList.getItems(camlQuery);
context.load(listItems);
context.executeQueryAsync(ReadListItemSucceeded, ReadListItemFailed);
}
function ReadListItemSucceeded(sender, args) {
var itemsString = '';
var enumerator = listItems.getEnumerator();
while (enumerator.moveNext()) {
var listItem = enumerator.get_current();
itemsString += 'Modified On: ' + listItem.get_item('Modified');
}
$("#P1").append(itemsString);
}