I am looking for a way to send an email with Google App Script (I know how to do that) which includes an approval button/link. When the user clicks the link/button in the email to approve the request, I want to trigger a script (this is the part I do not know if possible from email) which goes back to the Google Sheet and changes a value in a cell.
Example:
User A submits a request using google form, and a new row is appended in SheetA. With some formulas, I automatically associate an ID = X to that request/row. A script will then send an email to user B to ask to approve the request of user A. User B will click a link in the email and the script will find the record X in SheetA and update a value in that row.
You can create a simple web app, using code like
function doGet(e) {
params = e.parameter;
var range=e.parameter.range;
var value=e.parameter.value;
SpreadsheetApp.openById('SHEETID').getRange(range).setValue(value);
return HtmlService.createHtmlOutput(`<b>${range}</b> set to <b>${value}</b>`);
}
publish it with "execute as me", "everyone, even anonymous" options,
and then exec it using a link
https://script.google.com/macros/s/SCRIPTID/exec?range=B1&value=100
Example sheet:
https://docs.google.com/spreadsheets/d/1jNEzil1dOtXj-Qc5ZVcZnd1fwGQ7V18irWIsH9G8to8/edit?usp=sharing
Update link:
https://script.google.com/macros/s/AKfycby5KYzQELQNS0y0uf0CwjwzoWkabCJywqkpph7wUUXoTGjERUg/exec?range=Sheet1!B1&value=500
I don't know of a prefect way to do this, but with a small work-around, it is possible.
Instead of "clicking an Approve button," the user could click an Approve link. This link would open a Google Form that is pre-filled with the a request ID and Marked as Approved. All they would need to do is submit the pre-filled form. The email would also contain a Reject link that would also pre-fill the request_id and mark Reject. (I recommend radio buttons for this question)
Then set up a trigger onFormSumit(). for this form that makes the appropriate edits to the spreadsheet when a user submits this form.
If you wanted to make the solution even more complicated, but perhaps avoid the second click, the links could be to a WebApp and you could code the site to automatically record the data in the url to Google sheet.
PS: Both solutions also work as a way to get read receipts for emails sent from Google Scripts.
Related
I want to add a special widget (e.g. in the start message) which will be have a Submit button. The user interacts with widget, then presses this button and the widget should add a result as a reply message.
The reply form sends a post request with some parameters. Where can I grab it?
Maybe there is a some plugin with such a feature?
I found these props as hidden form fields. I don't know how I missed them at first.
For feeds the similar information is stored in a global variable BP_Nouveau.
console.log(BP_Nouveau.activity.params);
I have some problem while getting data from another site. In this case I want to get the reservation data from the booking engine site and they want to pass the data to me with Google Tag Manager. I don't really understand what I should do when they just need GTM code. What I should create in my server to get the data from the booking engine with Google Tag Manager ?
This is the illustrations:
I have two sites called sites1.com and sites2.com. In sites1.com I put the Google Tag Manager scripts to push form submit data like full name, last name, email, etc. After somebody submit the form I want to get the submited data in sites1.com to sites2.com with Google Tag Manager. My problem is how to get the data after somebody submited the form in sites1.com in my sites2.com ?
Please anybody knows how to resolve my problem . Thanks in advance .
Well if they implement your GTM from site2.com into site1.com all you need to do is:
Create a trigger for the submit button on the form (use the ID o class of the element and check for the that the Page URL contains site1.com/)
Create a tag where you want the information to be send
Scrap the fields with javascript or ask them to push to the dataLayer the information you need (in this case you can build the trigger based on this event)
And SUPER important: check all your triggers so no other tag fires on site1.com
2.1:
Im not sure if i get where you want this information to be stored but keep in mind GA does not accept PII. On the other hand if you want this in some DB you can just create and endpoint and send the information as parameters. Example:
site2.com/booking_info?field1={{DL variable}}
And just use a Custom IMG tag.
Ive made something like this using API Gateway, Lambda and DynamoDB and it took me 15 mins to set up. (just to give you perspective)
-- EDIT:
Ones you have the information avaliable you can send it to your database using two methods:
Using a HTML tag and making a request with javascript
Making a request with a custom image tag
On the past i ve just added the URL with parameters where you want the request to be made on an image tag and worked perfectly for me.
-- More info:
The custom image tag requests an image from a particular URL. The interesting part is that by making the request you’re actually transmitting information to a server. For example, if you request an image via URL https://www.example.com/something?parameter1=good¶meter2=123, the receiving server processes parameter1 and parameter2 and acts accordingly (e.g. registers those parameters as an event).
Source.
I’m working in modifying a google form to process information from my team. I want them to provide information on New Projects and Existing Projects. If Existing Projects is selected, it displays a URL to take the user to another form. I want the confirmation page to only display the link to the next form if the user has selected “Existing Projects”.
I know previous answers on this site and from Google Help state that you cannot dynamically change the confirmation notice. However, I have written a function which takes the user response and changes the confirmation response using GAS .setConfirmationMessage(). However, this only takes effect using the onSubmit trigger, and the confirmation page is loading too quickly right now to change the information from the current response.
function pageDisplay(){
var form=FormApp.getActiveForm();
var formResponses=form.getResponses();
var lastFormResponse=formResponses.pop();
var itemResponses=lastFormResponse.getItemResponses();
var itemResponse=[]; //initialize array
for (var i=0; i<itemResponses.length; i++){
itemResponse[i]=itemResponses[i].getResponse();
}
switch (itemResponse[0].toString()){
case "Existing Project":
form.setConfirmationMessage("Thank you now please visit URL");
form.setConfirmationMessage(url);
break;
case "New Project":
form.setConfirmationMessage("Thank you for your new information").setShowLinkToRespondAgain(true);
break;
}}
Question: How can I slow down the loading of the confirmation page until after the script has run? Is this possible?
I am getting used to GAS but have no experience in HTML or webpage JS so please be detailed if it involves those. Thank you for your help!
Google Forms doesn't include a built-in feature to change published form behaviors like delaying the displaying of the confirmation page.
One alternative is to get control of the POST request to the Google Form app by using UrlFetchApp but this could unnecessarily over-complicate your a solution to be deployed as "production". If you still want to take this way, you should the use HTMLService to display a html form with a custom form submit action that will emulate the form action of the published Google Form.
I'm programatically creating a Google Form using Google App Scripts right now, and my script automatically generates a page for each of the respondants that the form will be emailed out to.
Currently, the form has a dropdown at the beginning that the person uses to select their page, and then it forwards them to it, however, I'd prefer it if the email already sent out a pre-responded form that already started them on their page.
The reason I'm throwing them all into a single form is because I'm using Triggers to detect the form's submission, and since I have more than 20 people that require a form, that would break the trigger limit.
EDIT:
Example code:
the Form.getPublishedUrl() function returns the URL to respond the form, starting on the first page, however, I would like a URL to respond to the form starting on the 3rd or 4th page.
While the FormResponse.toPrefilledUrl() will allow me to autofill the correct response on the first page, it will not allow me to start the responder on the page that he would be forwarded to based on his pre-filled response on the first page.
tldr; :
How do I get a link to a specific page on a Google Form using Google App Scripts?
This should be a comment but don't have 50 rep yet...
Why do you need various HTML pages?
I think you should refactor your code so every form is on the same HTML and everything shows and hides with Jquery or Javascript. You can send the same URL but with differente URL parameters.
If this isn't your case, you should post some code of yours and detail a little bit more your question. Also, wich limit does it triggers?
I am making a task list on my site, in which i will put different things to do..
In the end they will be asked to put in their email address and click submit.
Now This is what I want to do when they click submit:
The next day,(not right away!) they should get an email that should
link them to next task.
This should be automatic, and I just have to set the submit buttons
up with the right code provided by you.
It will be my great honor if a volunteer helps me out.
I am also using wordpress
This can be done using JavaScript and Java Servlets.
in action page call: action servlet.
Servlet Should be able to send the email at particular time.
How to send email automatically at particular time of day in javaClick here to see how to send an email at particular time
Try this too
You can't do this with just javascript. You will need that form to post to some back end server which can store the information (probably in a database), and process it at some point in the future when it is necessary.