0

Be gently, very noob at this. So I've just replaced a guy who got a promotion and I am a primary teacher who has only really vaguely dabbled with this. I have successfully created a script that will do a lot of the things I need (so now looking to finish the job). My app script creates planner for teachers on a large cale so that they can have them labelled and the week goes in and changes the info. Voila:

var fichier = DriveApp.getFileById('IDGOESHERE');
var newFichier=fichier.makeCopy("YOURGRADE LITERACY PLANNER TERM 1 WEEK 1");
var num=newFichier.getId();
var doc=DocumentApp.openById(num);
var body = doc.getBody();
doc.replaceText("abc123","TERM 1 WEEK 1");

It now works fairly well but I didn't know how to repeat it and then add one to the text, so I just copied it out heaps of times (one per each school week, not the end of the world). Any feedback here is welcome.

My real question though is this: I now need to go into each documents (there will be hundreds if not thousands) and link every document to our school website. My predecessor had the links in a sheet and just slipped them on to our website. Is there anyway of expanding the script so that it can publish the web address or even google doc ID of each newly created document into a spreadsheet (or text / doc).

This may not be possible, but if it were that would be amazing, would save me having to manually link all of the files week by week, one for each teacher over the year. THANKS!

  • You do realise that you are asking for a fairly substantial piece of custom code? Even if somebody was willing to write / help you with this question, you haven't provided nearly enough information for them to do so. I suggest that you ask you predecessor or head on over to the Google script documentation and start learning! This is a place were people offer help to those that they have made a reasonable effort in solving it themselves, it's not a code writing charity. – James D Feb 08 '17 at 12:53

1 Answers1

0

Yes, there is. After you create the doc there are 3 very useful methods you could call:

var name = doc.getName(); //returns the name in a string
var id = doc.getId(); //returns the id in a string
var url = doc.getUrl(); //returns a url to the document as a string

In the drive app, you will probably want to set the sharing permissions.

file.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.VIEW);

You will then want to open a spreadsheet and append a new row for the data

sheet.appendRow([name, id, url]);
Hink
  • 2,271
  • 1
  • 11
  • 8