sharing the folder created by google form and google script

I am a complete beginner and that is why I used an almost ready solution. However, the subsequent changes were beyond me

I used the solution available here to move the uploaded file to an individual subfolder

https://developers.google.com/apps-script/samples/automations/upload-files?hl=pl

Hhen I tried to share the subfolder. I modified the function as follows

function getSubFolder_(objParentFolder, subFolderName) {

  // Iterates subfolders of parent folder to check if folder already exists.
  const subFolders = objParentFolder.getFolders();
  while (subFolders.hasNext()) {
    let folder = subFolders.next();

    // Returns the existing folder if found.
    if (folder.getName() === subFolderName) {
      return folder;
    }
  }
  // Creates a new folder if one doesn't already exist.
  return objParentFolder.createFolder(subFolderName)
    .setDescription(`Created by ${APP_TITLE} application to store uploaded Forms files.`)

    //
    .createPermission("[email protected]", "writer");
}

Ultimately I would like the email address to be created based on one of the responses from the form.

2

Passing an Email based on OnFormSubmit(e)

Please feel free to raise any questions if you have one, because as of the moment I have limited information about your whole code and how does your form looks like.

Codes to be added based on the Sample you have sent:

You need to add something to grab the email from the responses. Assuming that you follow the shared documents in the article.

So based on the Link:

From this:

let itemResponses = e.response.getItemResponses();

To this

let itemResponses = e.response.getItemResponses();
var email = itemResponses[0].getResponse();//Change the Index by the counting where does the question falls and subtract 1. I.E: If the email is on question 2 then the Index or [0] should be on 1.

Note: It is just a declaration I am just making sure that it is declared correctly, based on the placement where it is supposed to happen on the code.

Please edit, something that resembles this in your code, that is currently not shared:

From this:

destFolder = getSubFolder_(destFolder, subFolderName);

To this

destFolder = getSubFolder_(destFolder, subFolderName, email);

Finally Update your Called Functions like this:

function getSubFolder_(objParentFolder, subFolderName, email) {

  // Iterates subfolders of parent folder to check if folder already exists.
  const subFolders = objParentFolder.getFolders();
  while (subFolders.hasNext()) {
    let folder = subFolders.next();

    // Returns the existing folder if found.
    if (folder.getName() === subFolderName) {
      return folder;
    }
  }
  // Creates a new folder if one doesn't already exist.
  return objParentFolder.createFolder(subFolderName)
    .setDescription(`Created by ${APP_TITLE} application to store uploaded Forms files.`)

    //
    .createPermission(email, "writer");
}

Info: What the code modification does is grab the email from the responses, pass the data on the parameters of the called function to have a more dynamic permission sharing.

Reference:

Event Objects

Form Response

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật