Assume that 3 people need to approve the request. The approvers that need to review the request are approvers X,Y,Z.
- User X gets an Email requesting that they review the request
- The email that user X gets will use HTML
- The HTML will have a link in it
- A link in HTML submits a GET request
- Whenever you click a link, or enter a url into the browser address
bar, a GET request is made to the url
- An Apps Script Web App is an Apps Script project that is published as
a Web App
- A Web App has a url that can be used to make a request to it
- When the url (link) is used, a GET request is made
- A GET request made to an Apps Script Web App will run the doGet()
function
- Once that doGet() function run, you can have your Apps Script code do
anything that you want
- It can get information sent in to it from a search string
- Then send out another email to user Y
So, when user X clicks the link, the url needs to have information
appended to the url in the form of a search string
httpz://the link?whichUser=X&approved=true
You can get the user and whether it was approved or not from the "event object" often designated by the letter "e"
function doGet(e) {
var whatUserJustReviewed,isItApproved;
//Get the values passed in from "e" which is the event object
eventParam = e.parameter;
whatUserJustReviewed = eventParam.whichUser;
Logger.log(' whatUserJustReviewed : ' + whatUserJustReviewed )
isItApproved = eventParam. approved;
switch (whatUserJustReviewed) {
case "X"
if (isItApproved === 'true') {
// //Send an email to the next user which is Y
}
break;
case "Y"
if (isItApproved === 'true') {
// //Send an email to the next user which is Z
}
break;
case "Z"
if (isItApproved === 'true') {
//Send an email to all involved who need to know that it was approved.
}
break;
default:
console.error('There was an error getting user or status');
};
}
doGet()function. An HTML form can make a POST request todoPost()- Alan Wells