0

I have a .csv file in a file library, i would like to know if is there way to display in some page when the .csv file was last modified, and who did.

Does anybody know any code in to get this information using javascript?

0

Here is a sample code that can be added to a page in script editor web part. Assuming the ID of the csv file in the library is known. Otherwise you need to adjust the camlquery. Please modify it to store the modified by and last modified date values to holders/containers.

var siteUrl = '/';

function retrieveListItems() {

    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('library_title');

    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'ID\'/>' + 
        '<Value Type=\'Number\'>1</Value></Eq></Where></Query></View>');
    this.collListItem = oList.getItems(camlQuery);

    clientContext.load(collListItem);

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), 
                                    Function.createDelegate(this, this.onQueryFailed));        

}

function onQuerySucceeded(sender, args) {

    var listItemInfo = '';

    var listItemEnumerator = collListItem.getEnumerator();

    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        listItemInfo += '\nID: ' + oListItem.get_id() + 
            '\nModified By: ' + oListItem.get_item('Editor').get_lookupValue()+
            '\nLast Modified Date: ' + oListItem.get_item('Modified').format('dd/MM/yyyy, hh:ss');
    }

    console.log(listItemInfo.toString());
}

function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

and the output is

ID: 1
Modified By: Ahmad Zia
Last Modified Date: 19/08/2014, 08:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.