view pdf file in a new tab after save on drive

345 views
Skip to first unread message

Ahmed General

unread,
Nov 21, 2021, 1:00:29 AM11/21/21
to Google Apps Script Community
  I need help I need a script to view the pdf file in a new tab after making a save
Screenshot.png

Brett Grear

unread,
Nov 21, 2021, 5:34:59 AM11/21/21
to Google Apps Script Community
What context is the script running in. Is it in a Spreadsheet container?
If so, you can show a modal dialogue using HtmlService that either provides a clickable link to the PDF or you can trigger it to open automatically.

Ahmed General

unread,
Nov 21, 2021, 5:41:08 AM11/21/21
to Google Apps Script Community
Screenshot.png

‫في الأحد، 21 نوفمبر 2021 في 1:35 م تمت كتابة ما يلي بواسطة ‪Brett Grear‬‏ <‪bgrea...@stvps.co.uk‬‏>:‬
--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/oARd1Sg3Q0c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/a835f695-8de4-45f6-892a-2add76bfb9a8n%40googlegroups.com.

Alex

unread,
Nov 21, 2021, 11:10:49 PM11/21/21
to Google Apps Script Community
Ahmed,

As Brett already said, you have to run this code from your UI container.


Look at the part 

/**
 * User action
 */
function userActionOpenMyFile() {
  const file = DriveApp.getFileById(
    '17mpcNilHA43kWqYm8qHAwiwAqFJ1DQ9QENBXHa6CoDM'
  );
  openUrlInBrowser_(file.getUrl());
}

Reply all
Reply to author
Forward
0 new messages