Automatically Creating new folder in Google Drive from Appsheet for each raw - google-apps-script

i'm new to Appsheet,
i have built a new app from appsheet for a small team,
the app function is to mange customers (contacts app)
in my app-sheet there is a view called (customers),
this customers View linked to google spreadsheet called (customers_DB)
(customers_DB) contain customers data rows
Customers ID
Customers Name
what i want is when someone add a new customer to the (customers_DB) spreadsheet
automatically it create a new folder in google drive in the customers folder
the folder must be named with the customer ID
and display this directory in the customer contact view in app-sheet
so the users can view the files in this directory in app-sheet and can upload&download files from this directory
https://www.googlecloudcommunity.com/gc/AppSheet-Q-A/Creating-new-folder-in-Google-Drive-from-Appsheet/m-p/518827#M201484
i need to make google script that create folders for each new raw

Related

How Can I add row in google sheet when I Create a New Folder in Google Drive?

How Can I add row in google sheet when I Create a New Folder in Google Drive?
I have folder in google drive
and I need when I create a new folder inside it create a new last row in google spreadsheet and add hyperlink with new folder name in column E and the local date created in column G and the parent folder name in column M

Rename files in Google Drive that have been collected through Google Forms

I am collecting Friends photos through a Google Form. The Form has only two fields Name (text) and Photo (upload).
The uploaded photo is stored in a folder in Google Drive and a hyperlink appears in the Google sheet to the name.
The issue I am facing is that the photo stored in Google Drive usually has a name generated while taking the photo and is not the name of the person whose photo it is. I want the photo file name to be the same as the person's name.
I don't know much of Google Scripts and would like help in using a script to rename the files in the Google Drive with the name of the uploader which is in the Google Sheet.
To rename uploaded files in Google Drive that have been collected through Google Forms you can
create your own apps script that will process all files received via Google Form, as described here or here, or
use my Google Forms add-on Form Uploads Manager that renames the uploaded files, move them to the Google Drive folders you specified and can add a description for each uploaded file, which makes it easy to find files using the built-in Google Drive search. A detailed description of the add-on settings is available on the app home page.
Disclaimer: This is my Google Forms add-on, which I created for my own purposes, and after successful use I posted it on the Google Workspace Marketplace. After a 1 week trial (which might be enough to reach your goals), a paid add-on subscription is required.

Get ID of newly created Folder in Google Apps Script

As part of a Google Apps Script project, I'm trying to move the active spreadsheet and several uploaded files to a new folder that is created within a shared directory.
I have been able to create the new folder with:
DriveApp.getFolderById(parentFolder).createFolder(rename);
But to be able to move the files where I need to know the ID of the folder that's just been created.
The rest of the code works ok - if I just put in a string as another folders ID everything gets moved. I'm just stuck on actually finding that new folder ID.
Any ideas?
ta
You can retrieve folder ID using "getId()". For example, your code can be written as follows.
var id = DriveApp.getFolderById(parentFolder).createFolder(rename).getId();
If the folder name is only one on Drive, you can retrieve folder ID from folder name like below.
var id = DriveApp.getFoldersByName(rename).next().getId();

nested folders in Gmail

We have a few email accounts at work that are shared by number of people and a silly policy of emails older then 365 days old being automatically purged. So we need to back up all email correspondence by saving them as pdf to Google Drive.
Once a task is completed than all relating emails are moved into a folder. The script I have takes care of saving the emails. But I'd like to replicate the Google inbox nested folder structure in Google Drive with the script to save emails in the appropriate folder.
Example:
2015/North/city 1/email
inbox folders
thanks in advance
The email is in "2015/North/City 1" in Gmail and want to save it in the identical folder structure in Google Drive
The pseudo code is:-
Find "2015"
If not exists, create it
Save ID of 2015
Find "North" with a parent of 2015's ID
If not exists, create it
Save ID of North
Find "City" with a parent of North's ID
If not exists, create it
Save ID of City
Create your email with City's ID as its parent
It's also possible to fetch all folders in a single query, and then construct your own hierarchy in memory, but since you're using AppScript, network latency shouldn't be a big deal.

Grouping folders by name automatically in google drive?

I have a form on my website where submissions are sent to Google Drive and a file created according to ClientName, each submission creates a new file, but what I would like to do is group them by ClientName parameter within Drive automatically.
I have found online how to group but you must first know the ClientName of the file in which to group, is there no way to automate this in script so that new files are automatically grouped as and when they come into drive?
Any help/guidance would be much appreciated.
Thanks
For this you can
Create a folder with ClientName under DriveApp .
Before adding the file to your drive search for that particular
folder using searchFolders(params)
Add the file to the particular folder. That way all the files are
grouped by the ClientName.
Hope that helps!