I have built a Google Slides presentation using Google Apps Script.
var docId = DriveApp.getFileById(templateId).makeCopy().getId();
var newDoc = DriveApp.getFileById(docId).setName(newDocName);
var newDocUrl = newDoc.getUrl(); // This gets the URL of the editing view. I want the presentation view.
How do I publish it then get the URL of the published presentation?
Here are the docs. I'm looking for something like:
var publishedNewDoc = newDoc.publish();
var newDocPublishedUrl = publishedNewDoc.getPublishedUrl();
If my understanding is correct, how about this answer?
In order to publish the Google Docs, you can use the method of Revisions: update in Drive API. About this, you can see a sample script as one of several answers.
Before you use this script, please enable Drive API at Advanced Google services.
var slidesId = "###"; // Please set this.
Drive.Revisions.update({published: true, publishedOutsideDomain: true, publishAuto: true}, slidesId, 1);
When you publish manually the Google Slides to the web, you can see the URL like https://docs.google.com/presentation/d/e/2PACX-###/pub
. Unfortunately, in the current stage, this URL cannot be retrieved. So as a workaround, the published URL can be retrieved using the file ID. The published URL with the file id for Google Slides is as follows.
https://docs.google.com/presentation/d/### file ID ###/pub
If I misunderstood your question and this was not the result you want, I apologize.