I am trying to create a Google script linked to a spreadsheet containing multiple email ids and some data related to them. The script will send an email containing an HTML button to every id in the spreadsheet. What I am doing is that when the user clicks that button in its mail, it will fetch the data from the spreadsheet respective to that email id.
What I am unable to do is how to fetch user id of that particular user when that user clicks the button (that script sent in the mail) and send it with the POST response, so that script can know which user is asking for information and fetch data from spreadsheet only for that particular user.
I followed Casper's suggestion and used the email address of the active user and then split it to get the id part which then I can verify.
Related
Is it possible to access my Google contacts from Google Sheets? I've created a simple spread sheet where I enter information for my drivers. Once the data on a row is entered it may be modified by other users that access the same sheet, but eventually - one of the users will need to send the data in that row to a specific driver via email. I currently accomplish this by using a Google Sheets Script to take the row values and build a mailto: hyperlink onEdit() in the last cell:
var emailtoString = '=HYPERLINK("mailto:changethis#address.com?&subject=' + subjectData + '&body=' + formatedData + '", "send email")';
e.source.getActiveSheet().getRange(row,9).setValue(emailtoString);
Which is working as expected and allows for whatever users is clicking the hyperlink to open the preformated gmail in their account - they can then delete the "changethis#address.com" email address that is allowing the hyperlink formula to create and then they have access to their contacts in the to: field - so if they start typing a user name, a selection list displays to let them select the contact.
This works, but separates the process of sending the email from the sheets script - just to get access to the drop down contacts list. If I could access that TO: dialog directly from the sheet cell - so the user sending the email is really just selecting an address from their contacts, then I could use the sheets script to just send the email message without having to open a gmail message and I could further flag another cell as "Message sent to emailaddress". By using the hyperlink it is making it difficult for me to figure out how to set a flag letting other users know an email has already been sent to this driver. So I am wondering if its possible avoid all this hyperlink creation and instead, just present the user(s) of the spread sheet with a selection dialog from the user accessing the sheets personal contacts so they can select someone to send the email and I can script sending the email rather than building the Hyperlink to open Gmail.
From the question
Is it possible to access my Google contacts from Google Sheets?
Yes it's possible. Use the Contacts Service (ContactApp)
Reference
https://developers.google.com/apps-script/reference/contacts
Related
Create a Contact Group via Google Spreadsheet
I know there is a getRespondentEmail() which retrieves the email id. But if i'm understanding this correctly, it is only when user submits the form then I'll get information through this. Is there a way to get email id when form is loaded for response. Objective is as follows:
1) Get email id when form is loaded for response
2) access a google sheet and filter data based on this email ID
3) provide the filtered list as a drop down for selecting within the form.
Answer:
This is not possible using Google Forms.
Explanation:
In order to get user information before a user has submitted a form, direct access to the browser session must be retrieved by Google's server before form submission. This isn't done.
Until a form has been submitted by the user, therefore giving explicit permission to submit their responses and email address, no information is communicated to Google's servers and as such the email address can not be retrieved before the user submits their answers.
Users are even prompted that their email will be sent with their responses once they submit if the Collect email addresses checkbox is ticked in the Form Settings, as this is personal information and they need to decide if they wish to send this information or not:
Implementing this would be a privacy issue so I can not foresee Google creating this option in the future either.
How can I get the current user's email address using Google Apps Script?
For example, if my Google Sheet is shared among different users and multiple users are accessing the same sheet concurrently.
I'd like to capture the individual user name for whoever has modified text in Column A and record it in column Z.
I've tried using:
Session.getActiveUser().getEmail();
However this isn't working, it returns nothing.
I created a Google Form that send its results to a Google Sheet for further calculations. Therefore, I'd like to display the results of those calculations to the user once he has sent the Google Form (either instantly or via email).
How can I achieve this ? Should I use a module ? Or a Google Apps Script ?
Thanks for your time
Considering that, You are collecting data from multiple user into the spread sheet collect their email Id's as well along with other data,
How to get email Id column in spreadsheet?
Go inside google form edit mode -> see the settings icon from the right corner of the page > click on that -> check the Collect email addresses checkbox -> Save.
Now, you will have Email Address column in the spreadsheet.
Lets suppose you are receiving the marks of 3 subject, calculate the sum of those these 3 values, same for each users records(row) in loop or use VLOOKUP/ formula to calculate sum, get email address from the same row of the respective user and send mail to that user using MailApp api and add sum inside email body with some text formatting.
Perhaps, check out two addons for Google sheets, autoCract and Docotpus. We use them all the time to get and send student's results. They are very helpful.
I am using a Google form that collects data and upon submission it needs to show a unique reference ID to the person who submits data. The responses spreadsheet generates the unique ID however and I want to add that to the respondent email.
I used Google form notifications add-on and could enable sending out a mail to the respondent. The thing is how can I add the generated ID or the time stamp of the response to the email? Check the image below.
I am new to this and I found a similar question here but I am confused how to use it to accomplish this work.
Unique "reference" for form response?
Earlier there was a script gallery that we can search and add script add-ons and could find the FormMailer add-on that does this without any hassle upon the addition of a new record to the spreadsheet. But that feature is no longer there and a script editor is present and I am confused with this new method. https://www.youtube.com/watch?v=-o6JCQcLsBo
Please help me to do this.