0

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.

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!

1
  • Where does your forEach() end? It appears to be missing its closing parenthesis. Indentation may help you here.
    – mykaf
    Nov 16, 2021 at 20:41

2 Answers 2

0

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
 }
2
  • 100% right i couldnt see that thanks! gotta keep eye on that! appreciate the help!
    – ACK
    Nov 16, 2021 at 20:47
  • The script editor to me right where it was at
    – Cooper
    Nov 16, 2021 at 21:02
0

You're missing several closing brackets and parenthesis.

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]});
    });
}
2
  • 1
    THANKS! i couldnt see them for some reason but greatly appreciated!
    – ACK
    Nov 16, 2021 at 20:46
  • No problem. Always appriciate upvotes if you found the answer helpful :) Nov 16, 2021 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.