Skip to content
Advertisement

I need 2 different buttons, to create new folder and create a new PDF in that folder

I’ve been struggling to build a specific weekly stock system reports. So to give you a basic overview, I have a mastersheet that I want to generate reports from, triggered by an UI button. The first step however is to create a folder for that week to place the PDF’s in. I can create the folder, and I can generate the PDF in my root Google Drive folder, but I can’t seem to move the PDF anywhere after that. I have attempted to use .moveTo() but I can’t get that to work. Does anyone have any advise?

JavaScript

Advertisement

Answer

Description

These types of situations are hard to test because the circumstances are specific to the OP questioner. However, I believe this will work.

Using the PropertyService Script Properties, store the newly created folderId and then get that id from Script Properties to move the file.

A note of caution, I didn’t check for the case if the week changes and a new folder is not created, the pdf will go to the previous week folder.

Regarding creating a button and linking a function to the button see this article Buttons in Google Sheets

Script

JavaScript

Reference

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement