Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get file ID to send mails from GoogleSheets/Script

I’m new to coding and i’m having issues with a code where i keep getting "Error Syntaxis: Missing ) after argument

This is my current code:

    function myFunction(){
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet('Form Responses 1');
  const url = sheet.getRange().getValues();
  url.forEach(function(row,index){
    if (index === 0) return;
    if (row[19]) return;
  const idFile = url.match(/[-w]{25,}/);
  const file = DriveApp.getFileById(idFile)
  const blob = file.getAs(MimeType.PDF)

  var message = 'Thanks for your interest this will be the first step'
  var mail = row[2]
  var team = row[8]
GmailApp.sendEmail(mail,team,"Subject",message,{attachments: [blob]})

This is my second script, the first one i built it to create PDF for each new google form entry and in column 19 the PDF link is written. The idea is that after that PDF linked is created it takes the file ID and then sends it automatically to the person that filled the form with CC to my team if there is no link created then it should not send it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But i have researched and i honestly don’t know much to identify my error, i hope anyone can help me i would appreciate it.
Either not by giving the answer but help in any form would be appreciated!

>Solution :

Missing parenthesis after the arrow function see comment below

function myFunction() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet('Form Responses 1');
  const url = sheet.getRange().getValues();
  url.forEach(function (row, index) {
    if (index === 0) return;
    if (row[19]) return;
    const idFile = url.match(/[-w]{25,}/);
    const file = DriveApp.getFileById(idFile)
    const blob = file.getAs(MimeType.PDF)

    var message = 'Thanks for your interest this will be the first step'
    var mail = row[2]
    var team = row[8]
    GmailApp.sendEmail(mail, team, "Subject", message, { attachments: [blob] })
  });//your missing the parenthesis here after the arrow function
 }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading