How to create variables in Google Forms to output to Zapier

32 Views Asked by At

I have a Google Form that works with Zapier. In addition, on submit of the Google Form, I created a Google Apps script to create a folder in Google Drive. But now I would like to output the Google Drive locations to Zapier as variables to use in the next workflow process.

In my Google Apps script I currently have:

function new_video_response(){
  try{
    const form=FormApp.getActiveForm();
    const folder=DriveApp.getFolderById('FOLDER_ID');
    const responses=form.getResponses()[0];
    const answers=responses.getItemResponses();
    const NAME=answers[0].getResponse();
    const found=folder.getFoldersByName(NAME);
    const subfolder=found.hasNext()?found.next():folder.createFolder(NAME);
    const datetime=Utilities.formatDate(new Date(),'PST','yyyy-MM-dd HH:mm:ss');
    console.log(datetime);
    const subsubfolder=subfolder.createFolder(datetime+' PST');
    answers[10].getResponse().forEach(ID=>DriveApp.getFileById(ID).moveTo(subsubfolder));
  }
  catch(error){console.log(error);}
}

When a form response is submitted I receive the following standard variables (in Zapier):

enter image description here

Is there a way or method to also pass the newly created Google Drive folder location to Zapier as well? Something like:

return {'subfolder_url':subfolder.getUrl()};
0

There are 0 best solutions below