Solved

googledoc spreadsheet last modified date

Posted on 2011-03-19
5
1,778 Views
Last Modified: 2012-08-13
I am writing a script in a google doc spreadsheet that needs to check the last modified date of another google doc spreadsheet. How can I retrieve the last modified date of a google doc spreadsheet if I know its URL or key already?
0
Comment
Question by:reggieperrin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:torvir
ID: 35173272
I tried it and got it to work with this script. The first line "var thisSheet..." and the last line are used only to be able to print the date in the present spreadsheet cell A1.
The file I am checking change date of is the file named "fileToCheckChangeDateUpon" which is a dummy file I created.

function dateOfTestfile() {
  var thisSheet = SpreadsheetApp.getActiveSheet();
  var files = DocsList.getFiles();
  var otherFileChangeDate = "Didn't find it";
  for (var n = 0; n < files.length; n++) {
    if (files[n].getName() == "fileToCheckChangeDateUpon") {
      otherFileChangeDate = files[n].getLastUpdated();
      break;
    }
  }
  thisSheet.getRange(1, 1).setValue(otherFileChangeDate);
}
0
 

Author Comment

by:reggieperrin
ID: 35184982
You rock! I tried your solution and it worked! However it is taking too long to go through all my files. How would I get it to only add jobs that start with "Job" into the files[n] array, before it starts searching through them?
0
 
LVL 5

Accepted Solution

by:
torvir earned 500 total points
ID: 35190583
If you know the file-ID you could use this syntax:
var file = DocsList.getFileById("t314159");

The script then becomes:

function dateOfTestfile() {
  var thisSheet = SpreadsheetApp.getActiveSheet();
  var file = DocsList.getFileById("t314159");
  var otherFileChangeDate = file.getLastUpdated();
  thisSheet.getRange(1, 1).setValue(otherFileChangeDate);
}
0
 
LVL 5

Expert Comment

by:torvir
ID: 35191008
The ID is the string in the URL of the document between "key=" and "&"
0
 

Author Closing Comment

by:reggieperrin
ID: 35311687
Fantastic solution! Thank you so much!
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question