I have a AppScripts code for creating an expiry date for a Google form. In the code the initial time from which the user can submit a response has to be dynamically changed depending upon the time at which the form goes live every time. This is because of the use case of the form. I can't allow the administrator to go to Script editor and change the value manually everytime he wants the Form go live.
Is there a possibility through which the date can be put in dynamically through an interface.
Here is the link from which I have taken the code.
And in this context I am talking about the variables named:
FORM_OPEN_DATE and FORM_CLOSE_DATE.
You could make a sideBar or a popup with the Html Service and have a little form or prompt dialag where the user can input the variables
Related
I am designing a ticketing system that runs through google forms and sheets. I want the agents to never have to interact with the actual sheet. I want to have a link/button in the email ticket where the agent can mark as resolved and the value in a cell in the sheet gets changed automatically.
Is this feasible?
It is possible and there are a couple ways to do it. I would suggest the below slightly different method than what your question asks (what if they accidentally click it!?).
Since you're already using google forms, I would send your people a link to another form that confirms a ticket should be closed. You code the link to pre-populate the ticket number to ensure that there's no human error in making sure they entered the proper ticket number.
See example to a form here with a link that will populate the form with a number from the link (I used your question #)
Once the user clicks submit, you can use that event to have your app script go modify your spreadsheet accordingly.
I would like to use a Google Form as a sign-in and sign-out sheet on a single computer (kiosk style), and I am already aware of the built-in setting where once the form is submitted it gives the option to click to go back to a blank version of the form (so that someone else can make another entry). However, it would be handy to have a script that when the form was submitted it would automatically (without having to click) send the page back to a blank version of the form. Does anyone know a way to do this?
I did some research about how to possibly do this using openById or openByURL and kept getting an error that the function didn't exist. I then read on another StackOverflow question that for security reasons, Google removed these functions for use within a custom function.
I am trying to record the total time taken to complete and submit a Google form.
My logic is simple that the following code would record and put the timestamp as a multiple choice option.
Then upon submitting the form, we get a time stamp anyway but along with that, we would get the initially recorded timestamp as an answer to that question.
This is my cute little code:
function initial() {
var form = FormApp.getActiveForm();
form.getItemById(1589920082).asMultipleChoiceItem().setChoiceValues([new Date()]);
}
I have set the trigger as OnOpen but surprisingly, it does not renew the timestamp every time I open the form. Theoretically, it should record the time when the form was open but I think I am missing something here.
On the other hand, if I change the trigger to OnSubmit, it starts recording fresh timestamps every time I submit the form. But I don't want that as we get submission timestamps anyway. What I am trying to record is the time the form was open.
I know this question was asked a year ago, but here is a workaround I just came up with.
Have 2 forms! The first form can be a disclaimer, instructions, etc. The second form is the original form you intended for the users to fill out. Turn on email collection for both, so you can know which user submitted the test.
Get the sharing link and in the settings of the first form add the link in the confirmation message:
Then link both forms into a spreadsheet and you will see the time stamp of each submissions. From there you can easily do a calculation to determine the duration.
Unfortunately you cannot have any code executed when user opens form for filling in, as onOpen trigger is not supposed to be run in this case:
https://developers.google.com/apps-script/guides/triggers/#onopen
The onOpen() trigger runs automatically when a user opens a spreadsheet, document, or form that he or she has permission to edit. (The trigger does not run when responding to a form, only when opening the form to edit it.)
There is an open feature request in Google Issue Tracker to introduce some kind of onOpen trigger when form opened for response, you can "star" it to make it more possible to appear: https://issuetracker.google.com/issues/63985842
I have a Google Form and a script and a script bound to the form.
I'm trying to get a function to run when a user fill in the form.
But the only function I get to run is when a hook it to the OnFormSubmit trigger.
No other function is running, no matter what I try.
Can I run a function i Google App Script on initial load when a user is filling the form? Is this possible?
Thanks
More details (I'll accept some other way to accomplish the task):
the function should capture some url parameters I pass to the form, and send it over to Google Analytics... I believe that part is solved here: Google Forms & The Measurement Protocol
As the form has several pages, the parameters I pass to the first page gets lost when the user goes to next pages, so I cannot capture them when submitting the form - therefore I'm trying to do it whenever the users first edits the form.
I tried to add the params as prefilled fields on a hidden page, but if it is hidden then it too gets lost on submitting...
Since Sandy did not write out an answer, I will.
You cannot execute Apps Script as part of a form when the user visits it. You can't modify a form as the user is filling it out (Dynamic form...etc). If you need this type of behavior, you will need to create your own form as part of a Apps Script Web App.
Web App information: https://developers.google.com/apps-script/guides/web
I am using a form to collect booking details and have the script attached to the form (so that the form submit trigger will trigger when the response is edited, which the spreadsheet bound version does not allow) which sends an email, schedules calendar events, creates confirmation documents etc on form submit. Using if statements I have provided the user the ability to avoid 'click the box to not send the customer an email on submit' functionality so that the form responses can be edited without triggers the automated functions, but that relies on the user remembering to click those boxes.
A better solution would be to be able to have the script, as its final function, change the item response, so that when the form is edited in future, the automatic functions are already disabled.
I do not want to create a new form response (although it would be possible to tweak the pre-populated url to create a duplicate with the appropriate changes)
FormResponse.withItemResponse(response) specifies that it doesn't work on stored responses
It is so easy to view form responses, and with the native edit response url functionality I figured editing a single item response would be doable, but so far it has eluded me.
Is there a way to do this?
Thanks
At this time Form responses could only be created programmatically, they can't be edited programmatically. Consider to submit a feature request through Google Apps Script Issues