Obsolete
Status Update
Comments
st...@gmail.com <st...@gmail.com> #2
I ran into the same issue. I had multiple forms linked to one spreadsheet and needed the form id of the submitted form. I eventually found a workaround.
testFormSubmit(e) {
var responseEditUrl = e.response.getEditResponseUrl(); //gets edit response url which includes the form url
var responseUrl = responseEditUrl.toString().replace(/viewform.*/,''); //returns only the form url
FormApp.openByUrl(responseUrl).getId()); //gets the submitted form id
}
Hope this helps
testFormSubmit(e) {
var responseEditUrl = e.response.getEditResponseUrl(); //gets edit response url which includes the form url
var responseUrl = responseEditUrl.toString().replace(/viewform.*/,''); //returns only the form url
FormApp.openByUrl(responseUrl).getId()); //gets the submitted form id
}
Hope this helps
pu...@innovationcharter.org <pu...@innovationcharter.org> #3
[Comment deleted]
th...@innovationcharter.org <th...@innovationcharter.org> #4
The solution just broke for me yesterday -- somehow google is now generating magic responseEditUrl's that do not include the proper ID, so when I extract the URL as above, I get a non-existing document (even though the full edit URL works).
I found another workaround, which is to use the trigger UID to get to the form. Here's example code:
function getSourceFromTrigger (event) {
var form = undefined;
ScriptApp.getProjectTriggers().forEach(function (trigger) {
if (trigger.getUniqueId()==event.triggerUid) {
event.source = FormApp.openById(trigger.getTriggerSourceId());
}
});
Logger.log('Got form=%s',event.source)
}
I found another workaround, which is to use the trigger UID to get to the form. Here's example code:
function getSourceFromTrigger (event) {
var form = undefined;
ScriptApp.getProjectTriggers().forEach(function (trigger) {
if (trigger.getUniqueId()==event.triggerUid) {
event.source = FormApp.openById(trigger.getTriggerSourceId());
}
});
Logger.log('Got form=%s',event.source)
}
ry...@google.com <ry...@google.com> #5
Thank you for your reports. We have filed this internally.
[Deleted User] <[Deleted User]> #6
Has this been fixed?
ry...@google.com <ry...@google.com>
se...@google.com <se...@google.com> #7
This issue is being closed since it is fixed.
To get the source ID of the form you can e.source
on the onFormSubmitTest
function:
function onFormSubmitTest(e) {
Logger.log(e.authMode);
Logger.log(e.triggerUid);
Logger.log(e.source.getId());
}
Regards.
ma...@gmail.com <ma...@gmail.com> #8
Is this actually fixed? I seem to be seeing the same bug in 2022. OnSubmit(e) has e.source empty. I created a new issue https://issuetracker.google.com/issues/255141659
am...@gmail.com <am...@gmail.com> #9
Yep, this doesn't seem to be fixed.
`e.source` is returning the spreadsheet that the form is linked to.
`e.source` is returning the spreadsheet that the form is linked to.
Description
There is no source field for form submit event created by onFormSubmit() of FormTriggerBuilder in a standalone script.
If a script is bound to a spreadsheet, a source field appears.
However, it does not contain Form object but the Spreadsheet object.
Please provide a small sample script that reliably reproduces the issue.
The sample should run as-is or with minimal setup, without external
dependencies.
function myFunction() {
var form = FormApp.openById("a form id");
ScriptApp.newTrigger("onFormSubmitTest").forForm(form).onFormSubmit().create();
}
function onFormSubmitTest(e){
Logger.log(e);
MailApp.sendEmail("mail address", "report", Logger.getLog());
}
What steps will reproduce the problem?
1. make a form
2. make a standalone blank script, write the above script, and run myFunction to make a trigger for the form
3. respond the form.
What is the expected output? What do you see instead?
Accourding to
the output in mail should be
{response=FormResponse, source=Form, authMode=FULL},
but the actual output in mail is
{response=FormResponse, authMode=FULL}.
What is the project key (found under "File > Project properties")? The
project key does not give the Apps Script team access to your source
code or data. We use it to look up debug information about your script.
MbhzuVtZwb4GCealMFUsrJ68VJNknFO53
Please provide any additional information below.
When I make the same script as one bound to a spreadsheet, source field appears but it contains not the form object but the spreadsheet object.
To subsequent readers: If you are also experiencing this issue, please
click the star next to the issue number. We prioritize issues with the
most stars.