I have a script that I created in Google Apps Script that sends a slack message to a user with certain IDs on a list in a Google Sheet with a hyperlink. The list for each user does not contain the same number of IDs resulting in the hyperlink url for empty cells to appear in the slack message. Is it possible to skip or hide the hyperlink url for cells that are empty for each user. Apologies if this is not clear. Please see payload script below:
// custom slack webhook
var url = "https://hooks.slack.com/services/XXXXXSBGW/XXXXXXU1K/XXXXXXXXn9jfZXAAAAAA";
var payload = {
"channel": "#"+city[2],
"username": "Alerts",
"text": "Hi " + city[0] + "\n"+
"\n Here are your most pending kits for review.\n" +
"\n <https://google.com/maps/'"+"|"+city[5]+">" +
"\n <https://google.com/maps/'"+"|"+city[6]+">" +
"\n <https://google.com/maps/'"+"|"+city[7]+">" +
"\n <https://google.com/maps/'"+"|"+city[8]+">" +
"\n <https://google.com/maps/'"+"|"+city[9]+">" +
"\n Please review these kits as soon as possible.\n"
};
Generic Hyperlinks provided but basically columns 7 through 9 on the City spreadsheet are sometimes blank. Is it possible to skip these cells if blank or at least not make the url appear? When the cells are blank, usually the hyperlink URL is displayed in the slack message. Any guidance would be much appreciated.
You need to check each of those values to see if they're populated and only then add them to the message. Multiple ways you can do this, but maybe the most straightforward is to loop through the values, build an array, and then join the array.
// Example city array
var city = ["name", 1, 2, 3, 4, "city1", "city2", "", "city3"];
// Compile links
var linkStartIndex = 5;
var linkEndIndex = 9;
var links = [];
for (var i = linkStartIndex; i <= linkEndIndex; i++) {
var value = city[i]
if (value != null && value != "") {
links.push("\n <https://google.com/maps/'"+"|"+value+">");
}
}
// Compile full text
var text = [
"Hi " + city[0] + "\n",
"\n Here are your most pending kits for review.\n",
links.join(""),
"\n Please review these kits as soon as possible.\n"
];
var joined = text.join("");
console.log(joined);
You could potentially make that a little cleaner using map(), but it all really depends on how your data is structured. Personally, I don't like having a variable number of columns as they doesn't convert as neatly into arrays as variable rows do. I also prefer to work with objects where possible. Consider how generating this object from your city array might make your code easier to comprehend:
var record = {
name: 'Brian',
slackId: '123',
cities: [
'New York',
'London'
]
};
Related
I'm hoping to make (what I hoped was) a very basic script, where you can type part of a document name into a Google Spreadsheet, and underneath will appear the files in your Drive that have that word in their title.
As an example, I have two files in my Drive called "Rome Adventure" and "London Adventure", and the idea would be that if you typed "Rome", "London", or "Adventure" into a cell, the file titles would appear below.
So far I've got this:
function onEdit(e){
// Gets the edited cell, turns it into string
var activeSheet = e.source.getActiveSheet();
var range = e.range;
var input = range.getCell(1,1).getValue();
var SearchString = 'title contains "' + input + '"';
// Searches Drive for files with titles containing whatever you typed
// and appends titles to the spreadsheet
var result = DriveApp.searchFiles(SearchString);
while (result.hasNext()) {
var file = result.next();
activeSheet.appendRow([file.getName()]);
}
}
But unfortunately nothing is appended, regardless of what I enter. I've tried "Rome", "London", and just about everything else I can think of. Thinking I might have stuffed up something in the first section, I added
range.setNote('Last modified: ' + new Date());
in between the two sections, and that worked. So it's definitely just the DriveApp.searchFiles that I've stuffed up. I thought I might have stuffed up the StringSearch bit, but changing the line to
var result = DriveApp.searchFiles('title contains "Rome"');
still doesn't return anything.
I'm only an enthusiast-level programmer, and this is the first time I've asked a question on here. So forgive me if this is a stupid question, or it's not possible. I'm just at my wit's end trying to get this to work.
Nothing is wrong with your function. It's failing because of an undocumented restriction using the onEdit trigger to search DriveApp. If you run the script as is and then go to View > Execution transcript, you'll see the failure message at the bottom.
You can call the function successfully from a custom menu. Instead of watching for the edited row, use .getActiveCell(). It will search the string inside the selected cell on the spreadsheet. A working example is below.
function onOpen() {
SpreadsheetApp.getUi().createMenu("Search").addItem("Run", "searchFiles").addToUi();
}
function searchFiles() {
var string = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveCell().getValue();
var result = DriveApp.searchFiles('title contains "' + string + '"');
while (result.hasNext()) {
var file = result.next();
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().appendRow([file.getName()]);
}
}
When using Utilities.parseCsv() linebreaks encased inside double quotes are assumed to be new rows entirely. The output array from this function will have several incorrect rows.
How can I fix this, or work around it?
Edit: Specifically, can I escape line breaks that exist only within double quotes? ie.
/r/n "I have some stuff to do:/r/n Go home/r/n Take a Nap"/r/n
Would be escaped to:
/r/n "I have some stuff to do://r//n Go home//r//n Take a Nap"/r/n
Edit2: Bug report from 2012: https://code.google.com/p/google-apps-script-issues/issues/detail?id=1871
So I had a somewhat large csv file about 10MB 50k rows, which contained a field at the end of each row with comments that users enter with all sorts of characters inside. I found the proposed regex solution was working when I tested a small set of the rows, but when I threw the big file to it, there was an error again and after trying a few things with the regex I even got to crash the whole runtime.
BTW I'm running my code on the V8 runtime.
After scratching my head for about an hour and with not really helpful error messages from AppsSript runtime. I had an idea, what if some weird users where deciding to use back-slashes in some weird ways making some escapes go wrong.
So I tried replacing all back-slashes in my data with something else for a while until I had the array that parseCsv() returns.
It worked!
My hypothesis is that having a \ at the end of lines was breaking the replacement.
So my final solution is:
function testParse() {
let csv =
'"title1","title2","title3"\r\n' +
'1,"person1","A ""comment"" with a \\ and \\\r\n a second line"\r\n' +
'2,"person2","Another comment"';
let sanitizedString =
csv.replace(/\\/g, '::back-slash::')
.replace(/(?=["'])(?:"[^"\\]*(?:\\[\s\S][^"\\]*)*"|'[^'\\]\r?\n(?:\\[\s\S][^'\\]\r?\n)*')/g,
match => match.replace(/\r?\n/g, "::newline::"));
let arr = Utilities.parseCsv(sanitizedString);
for (let i = 0, rows = arr.length; i < rows; i++) {
for (let j = 0, cols = arr[i].length; j < cols; j++) {
arr[i][j] =
arr[i][j].replace(/::back-slash::/g,'\\')
.replace(/::newline::/g,'\r\n');
}
}
Logger.log(arr)
}
Output:
[20-02-18 11:29:03:980 CST] [[title1, title2, title3], [1, person1, A "comment" with a \ and \
a second line], [2, person2, Another comment]]
It may be helpful for you to use Sheets API.
In my case, it works fine without replacing the CSV text that contains double-quoted multi-line text.
First, you need to make sure of bellow:
Enabling advanced services
To use an advanced Google service, follow these instructions:
In the script editor, select Resources > Advanced Google services....
In the Advanced Google Service dialog that appears,
click the on/off switch next to the service you want to use.
Click OK in the dialog.
If it is ok, you can import a CSV text data into a sheet with:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('some_name');
const resource = {
requests: [
{
pasteData: {
data: csvText, // Your CSV data string
coordinate: {sheetId: sheet.getSheetId()},
delimiter: ",",
}
}
]
};
Sheets.Spreadsheets.batchUpdate(resource, ss.getId());
or for TypeScript, which can be used by clasp:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('some_name');
const resource: GoogleAppsScript.Sheets.Schema.BatchUpdateSpreadsheetRequest = {
requests: [
{
pasteData: {
data: csvText, // Your CSV data string
coordinate: {sheetId: sheet.getSheetId()},
delimiter: ",",
}
}
]
};
Sheets.Spreadsheets.batchUpdate(resource, ss.getId());
I had this same problem and have finally figured it out. Thanks Douglas for the Regex/code (a bit over my head I must say) it matches up nicely to the field in question. Unfortunately, that is only half the battle. The replace shown will simply replaces the entire field with \r\n. So that only works when whatever is between the "" in the CSV file is only \r\n. If it is embedded in the field with other data it silently destroys that data. To solve the other half of the problem, you need to use a function as your replace. The replace takes the matching field as a parameter so so you can execute a simple replace call in the function to address just that field. Example...
Data:
"Student","Officer
RD
Special Member","Member",705,"2016-07-25 22:40:04 EDT"
Code to process:
var dataString = myBlob().getDataAsString();
var escapedString = dataString.replace(/(?=["'])(?:"[^"\](?:\[\s\S][^"\])"|'[^'\]\r\n(?:\[\s\S][^'\]\r\n)')/g, function(match) { return match.replace(/\r\n/g,"\r\n")} );
var csvData = Utilities.parseCsv(escapedString);
Now the "Officer\r\nRD\r\nSpecial Member" field gets evaluated individually so the match.replace call in the replace function can be very straight forward and simple.
To avoid trying to understand regular expressions, I found a workaround below, not using Utilities.parseCsv(). I'm copying the data line by line.
Here is how it goes:
If you can find a way to add an extra column to the end of your CSV, that contains the exact same value all the time, then you can force a specific "line break separator" according to that value.
Then, you copy the whole line into column A and use google app script' dedicated splitTextToColumns() method...
In the example below, I'm getting the CSV from an HTML form. This works because I also have admin access to the database the user takes the CSV from, so I could force that last column on all CSV files...
function updateSheet(form) {
var fileData = form.myFile;
// gets value from form
blob = fileData.getBlob();
var name = String(form.folderId);
// gets value from form
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.setActiveSheet(ss.getSheetByName(name), true);
sheet.clearContents().clearFormats();
var values = [];
// below, the "Dronix" value is the value that I could force at the end of each row
var rows = blob.contents.split('"Dronix",\n');
if (rows.length > 1) {
for (var r = 2, max_r = rows.length; r < max_r; ++r) {
sheet.getRange(r + 6, 1, 1, 1).setValue(String(rows[r]));
}
}
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange("A:A").activate();
spreadsheet.getRange("A:A").splitTextToColumns();
}
Retrieved and slightly modified a regex from another reply on another post: https://stackoverflow.com/a/29452781/3547347
Regex: (?=["'])(?:"[^"\\]*(?:\\[\s\S][^"\\]*)*"|'[^'\\]\r\n(?:\\[\s\S][^'\\]\r\n)*')
Code:
var dataString = myBlob.getDataAsString();
var escapedString = dataString.replace(/(?=["'])(?:"[^"\\]*(?:\\[\s\S][^"\\]*)*"|'[^'\\]\r\n(?:\\[\s\S][^'\\]\r\n)*')/g, '\\r\\n');
I have an apps script which takes email addresses from one spreadsheet from multiple cells and adds them them to another spreadsheet into 1 cell only.
Currently the email addresses are added to that cell and separated by a ", ".
I would like to add the email addresses into that same cell but add a new line after each address.
I know it is possible to have new lines in a cell when manually adding text, by typing CTRL-Enter.
How can this be achieved in apps script?
I have so far tried to append "\n" or "\r" or "\r\n" to the string, to no avail, so I have reverted my code back to adding ", " instead.
sheet = SpreadsheetApp.getActiveSheet();
sheet.clear();
sheet.appendRow(["Num Emails", "Emails"]);
var LMEmails = "";
var count = 0;
for (var i = 0; i < reviewers.LMEmails.length; i++) {
if (count) {
LMEmails += ", " + reviewers.LMEmails[i];
} else {
LMEmails += reviewers.LMEmails[i];
}
count++;
}
data = [count, LMEmails];
sheet.appendRow(data);
If anyone could help, I would very much appreciate it
Regards
Crouz
After searching for the same question, this was my solution:
var stringToDisplay = 'FirstBit' + String.fromCharCode(10) + 'SecondBit';
then
workSheet.getRange(1,1).setValue(stringToDisplay);
output will be in a single cell, :
FirstBit
SecondBit
Google Spreadsheets seems to ignore the new line if there are no characters after it.
Using "/n" works fine as long as you add at least one other character after it, this could be a space as shown below.
For example:
var myString = 'First Bit' + "\n " + "Second Bit";
It should be:
data = [[count, LMEmails]];
I need LOTS of help on this one, but I think it's a procedure that would be helpful to other green-programers in the future.
I have a Google Form for people to fill that are new to our neighborhood. It, obviously, feeds a Google Docs spreadsheet. (Here's a link to a copy of the sheet that's just edited to black-out some of the personal data:
https://docs.google.com/spreadsheet/ccc?key=0AjsoIob8dJfodG9WN0ZmWUE1ek9rc3JrVFpDQ0J0OGc
)
One of the questions is which of our groups are you interested in joining. The Form asks the question, then allows the user to check off which of about 10 groups the new member is interested in joining. The data is then fed into the sheet listing all of the groups the new member wants to join in a single cell (that's column F).
The administrative task that I now need to tackle is going through all of the responses and pulling out the members who have said--for example--they're interested in joining the "Helping Hands" group, copying their e-mail address (which is in column X) and pasting it into the Google Groups sign-up sheet for that group.
This is understandable tedious. Especially because--again--we have about 15 of these Google Groups lists that need to be populated.
What would be great would be if I could write a little Google Apps Script that will go through the data in the sheet and give me a comma separated list of all the e-mail addresses that meet the correct criteria so that I could just copy-and-paste that into the Google Group sign up page.
In plain English, the regular expression should say this:
- IF column F contains Helping Hands
- AND IF column G does NOT contain Yes
- THEN add the contents of column X to an exported string, followed by a comma
- Repeat for every row in the sheet.
So here's the questions:
1) How do I do this?
2) How does this get triggered?
For the first step, I've already determined that the following regular expression will give me what I need:
/(^|, )Helping Hands($|, )/
I'm not sure how to augment that, though, to include the second required IF statement. I also don't know how to write the THEN statement. And--as I said above--I have NO idea how to trigger all of this.
Thanks in advance to anybody who can help! And the Newcomers to Sewickley also thank you! Please let me know if I can clear anything up.
Why don't you go further and set up a on form submit trigger that reads the groups and adds them automatically using the (yet experimental) Groups Services for Apps Script?
Such script is not very difficult to implement, maybe you should check the user guides and tutorials.
Looks like you are happy copy-pasting the list of email addresses if you get it in a comma separated format. So you can trigger it yourself when you need it.
You can use this code snippet
var options = ['Helping Hands','Book Club',...]; // Add all 10 options here
var GROUPS_COL = 5 ; //Column F
var COLG = 6;
var EMAIL_COL = 23 ; //Column X
var emailList = ['', '','',''...] ; // 10 blanks
var data = SpreadsheetApp.openById('ID_HERE').getSheetByName('SheetName').getvalues();
for (var i = 1; i < data.length ; i++){
for( var j = 0 ; j < options.length ; j++){
if (data[i][GROUPS_COL].indexOf(options[j]) != -1 &&
data[i][COLG] != 'Yes') {
// The entry in row i+1 has checked option[j]
if (emailList[j] != ''){
emailList[j] += ',' ; // Add your comma
}
emailList[j] += data[i][EMAIL_COL];
}
}
}
/* Now you have your comma separated list in emailList */
for ( var i = 0 ; i < 10; i ++){
Logger.log(option[i] + ':' + emailList[i])
}
Obviously, you have to tweak this code to suit your needs, but will give you a fair idea of how to proceed. The code has not been tested.
You have no idea how unbelievable stoked I am that this finally worked out. Thanks a million times over to #Sirik for sticking with it and writing the code and helping me debug it. It does EXACTLY what I want it to and it's just the coolest thing in the world to make it do EXACTLY what I wanted it to.
For the sake of posterity or anybody else who might want to be doing something similar to what I was doing, here's the exact code, all smoothed out, as implemented. You'll see that I added just a few extra bits at the end to e-mail the log to me and give me a dialogue box acknowledging that the script had run (I don't like that feeling of clicking the button and not SEEING something happen).
function Export_Groups_List() {
var options = ['1 & 2 Year Olds\' Playgroup','3 & 4 Year Olds\' Playgroup','Babies\' Playgroup','Book Club','Couples Night Out','Directory','Girls Night Out','Helping Hands','Membership','Newsletter','Serving Sewickley','Treasurer'];
var GROUPS_COL = 5; //This is column 5
var COLG = 6; //Column G
var EMAIL_COL = 23; //Column X
var emailList = ['', '', '', '', '', '', '', '', '', '', '', ''] //12 blanks
var data = SpreadsheetApp.openById('___').getSheetByName('Master').getDataRange().getValues();
for (var i = 1; i < data.length ; i++){
for( var j = 0 ; j < options.length ; j++){
if (data[i][GROUPS_COL].indexOf(options[j]) != -1 &&
data[i][COLG] != 'Yes') {
if (emailList[j] != ''){
emailList[j] += ', ' ;
}
emailList[j] += data[i][EMAIL_COL];
}
}
}
for ( var i = 0 ; i < 12; i ++){
Logger.log(options[i] + ': ' + emailList[i])
}
MailApp.sendEmail("matt#twodoebs.com", "Groups Export", Logger.getLog() + " \n\n" +
"At your request, you've been added to this Sewickley Newcomers & Neighbors Google Group." + "\n\n" +
"Using Google Groups allows us to always have up to date e-mail lists, make sure that people don't get bombarded with messages they don't want, and facilitate smooth communication between our members. If you have any questions about how to use the Google Groups service with your Newcomers & Neighbors membership, please send an e-mail to SewickleyNAN#gmail.com." + "\n\n" +
"Thank you and thanks for your participation!") ;
Browser.msgBox("OK. Check your e-mail for the export list. doebtown rocks the house!")
}
Evan Plaice provides a nice Google Apps Script that you can use in your own spreadsheet which essentially renders a menu that allows you to transpose a column using a "Text to Column" feature. https://webapps.stackexchange.com/questions/22799/text-to-columns-conversion-in-google-spreadsheets
I have a simple Google Form that collects data, and, using AppScript, sends confirmation emails to users who fill it out. After user submits the form, on confirmation, s/he will see a link to edit his/her response.
I'd like to include that link as a part of the confirmation email (Right now, it only shows up on the page.) How can I obtain the URL to edit a submitted response?
I am able to get the link to the Form through SpreadsheetApp.getActiveSpreadsheet().getFormUrl(). It gives me the following format: https://docs.google.com/a/domain.com/spreadsheet/viewform?formkey=<formKey>
The link however doesn't include the edit key, which is required for users to edit his/her response. The expected URL should look like this: https://docs.google.com/a/domain.com/spreadsheet/viewform?formkey=<formKey>&edit=<editKey>
Thanks for the help in advance!
-K
Edited:
Added a feature request on this: http://code.google.com/p/google-apps-script-issues/issues/detail?id=1345&thanks=1345&ts=1337773007
The answer that this wasn't possible by #Henrique Abreu was true until very recently. Google seems to have added getEditResponseUrl() to the FormResponse class and with that it becomes possible to use code like this to get the edit URL for a bunch of existing forms:
function responseURL() {
// Open a form by ID and log the responses to each question.
var form = FormApp.openById('1gJw1MbMKmOYE40Og1ek0cRgtdofguIrAB8KhmB0BYXY'); //this is the ID in the url of your live form
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
Logger.log(formResponse.getEditResponseUrl());
}
}
To make it automatically email the user as they respond one could add a trigger on form submit. As The situation I'm working with doesn't require people to log in with an apps account I don't have access to an email address automatically so I have a text question that captures the user's email address.
It does ask the question about whether or not editing the forms is what you want. I've been grappling with the relative advantages of editing an existing response or sending a prefilled form using toPrefilledUrl() so that I can see how things have changed over time. I guess this comes down to the value that tracking this will provide you.
If you are using Google Apps your responders can edit there form responses.
See: How to Edit Form Responses
--edit this is now possible. See other answers.
After user submits the form, on confirmation, s/he will see a link to
edit his/her response. I'd like to include that link as a part of the confirmation email
That is not possible, period.
That link is not accessible anywhere and one can't guess/construct it. But, there's some workarounds that might suit you (some suggested here that I'll re-phrase), e.g.
Send a per-populated form link and have the user re-send it. You'd need to have some kind of control field (e.g. the username), so you can know and delete/ignore his older submits. Possibly automatically via a script.
You could also develop and publish an apps-script GUI and send a link to this apps script plus a parameter that you generate where you can determine which entry you should edit. The down-side of this approach is that it's somewhat cumbersome and overkill to re-design the whole form on Apps Script. But again, it works.
At last, you could open an "Enhancement Request" on Apps Script issue tracker and wait until they and Google Spreadsheet/Forms team get together to develop a solution.
Here is a clear blog post that shows you how to do it step by step and explains what's going on under the hood for AppsScripts newbies:
http://securitasdato.blogspot.com/2014/11/sending-confirmation-emails-from-google.html
While collectively you can get there from the all the excellent answers provided here, the script from that post worked best for me.
Does this help - I haven't tried it but I was looking for the same thing a while ago and noticed this.
From this page
https://developers.google.com/apps-script/reference/forms/
code from there contains this:
Logger.log('Published URL: ' + form.getPublishedUrl());
Logger.log('Editor URL: ' + form.getEditUrl());
Jon
Great, script works! Thanks.
For newbies, like me: Just paste the andre's code for function SendConfirmationMail(e) into your spreadsheet's code editor and set 'on form submit' trigger to run it. That's in spreadsheet script editor, not form script editor.
You need to hack in some values. Read the code. For me the confusing one was the need to replace the ********COLUMN SEQUENCE EX 14****** with the sheet column number where you want the edit urls to end up. I used 39 which is one column more than my form was using up.
However, I got runtime probs in this part:
for (var i in headers) {
value = e.namedValues[headers[i]].toString();
// Do not send the timestamp and blank fields
if ((i !== "0") && (value !== "")) {
message += headers[i] + ' :: ' + value + "<br>";
}
}
Dunno why, but I replaced it with this:
for (var keys in columns) {
var key = columns[keys];
if ( e.namedValues[key]) {
message += key + ' :: '+ e.namedValues[key] + "<br>";
}
}
Works for me.
Try This: (Credits is not for me, because i merge two solutions of the third part)
Source: Send Confirmation Email with Google Forms
/* Send Confirmation Email with Google Forms */
function Initialize() {
var triggers = ScriptApp.getScriptTriggers();
for (var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
ScriptApp.newTrigger("SendConfirmationMail")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onFormSubmit()
.create();
}
function SendConfirmationMail(e) {
var form = FormApp.openById('***YOUR FORM CODE***');
//enter form ID here
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('***SHEET NAME***');
//Change the sheet name as appropriate
var data = sheet.getDataRange().getValues();
var urlCol = ***************COLUMN SEQUENCE EX 14******; // column number where URL's should be populated; A = 1, B = 2 etc
var responses = form.getResponses();
var timestamps = [], urls = [], resultUrls = [], url;
for (var i = 0; i < responses.length; i++) {
timestamps.push(responses[i].getTimestamp().setMilliseconds(0));
urls.push(responses[i].getEditResponseUrl());
}
for (var j = 1; j < data.length; j++) {
resultUrls.push([data[j][0]?urls[timestamps.indexOf(data[j][0].setMilliseconds(0))]:'']);
url = resultUrls[i-1]
}
sheet.getRange(2, urlCol, resultUrls.length).setValues(resultUrls);
try {
var ss, cc, sendername, subject, headers;
var message, value, textbody, sender;
// This is your email address and you will be in the CC
cc = Session.getActiveUser().getEmail();
// This will show up as the sender's name
sendername = "****YOUR NAME******";
// Optional but change the following variable
// to have a custom subject for Google Docs emails
subject = "Registro de Oportunidade submetido com sucesso";
// This is the body of the auto-reply
message = "Nós recebemos seu registro de oportunidade.<br>Muito Obrigado!<br><br>";
ss = SpreadsheetApp.getActiveSheet();
headers = ss.getRange(1, 1, 1, ss.getLastColumn()).getValues()[0];
// This is the submitter's email address
sender = e.namedValues["********COLUMN NAME OF DESTINATION E-MAIL************"].toString();
for (var i in headers) {
value = e.namedValues[headers[i]].toString();
// Do not send the timestamp and blank fields
if ((i !== "0") && (value !== "")) {
message += headers[i] + ' :: ' + value + "<br>";
}
}
message += "<br>Link to edit" + ' :: ' + url + "<br>";
textbody = message.replace("<br>", "\n");
GmailApp.sendEmail(sender, subject, textbody,
{cc: cc, name: sendername, htmlBody: message});
} catch (e) {
Logger.log(e.toString());
}
}
you can try to populate a form with the values given from that email address than delete previous answers ...
it's not a beautiful way but it can works ...
I don't think we have access to what that value is through the Spreadsheet API (which means Apps Script doesn't have it either). The closest I can think of would be the "key" value in this feed. You'd have to test to find out though. There's no other alternative that I know of other than accessing the Spreadsheet API directly. So first, you'd have to get the last row through the api use ?reverse=true&max-results=1