google-apps-scripttriggersgoogle-forms

Cannot get form response in onFormSubmit as it reads as undefined


When I try and get a form response from onFormSubmit(e), it returns {"authMode":"FULL","response":{},"source":{},"triggerUid":"604XXXXX"}, which does not include the values property. It seems like I am missing a scope but I dont know which one.

My code is

function onFormSubmit(e) {
    Logger.log(JSON.stringify(e));
    Logger.log('Named Values: ' + JSON.stringify(e.namedValues));

    var URL = e.namedValues['URL'] ? e.namedValues['URL'][0] : null;
}

My current scopes are

    "oauthScopes": [
        "https://www.googleapis.com/auth/forms",
        "https://www.googleapis.com/auth/script.external_request"
      ]

TL:DR I expect a valid e.values response, but it does not contain the values property.


Solution

  • There are two onFormSubmit triggers and each generates different Event Objects.

    Solution: