Does anyone know if it’s possible to have an appsheet formula in a google script when invoking action:Add? I would like to have extractemails() for my var senderDetails.
The topics you are dealing with on this your thread is highly complicated, not easy to discussed and solved…on the community place alone. I would suggest you go to the path to discuss through the partners like Able3, @MultiTech_Visions or other skillful Appsheet partners who are familiar with those kinds of stuffs. Not me.
@tingtingandrea
I have assumed that you have already a defined function in your script named as extractemails(). If you don’t have such a function, then the received error is so normal
And what the script originally does? The given payload is only a part of it I assume. I understand that it adds rows to a table, but how and from where you gather the data? Please be specific.
// extract emails from label in Gmail
function extractEmails() {
// get all email threads that match label
var lbl = "some label text";
var threads = GmailApp.search ("label:" + lbl);
// get all the messages for the current batch of threads
var messages = GmailApp.getMessagesForThreads (threads);
var emailArray = [];
// get array of email addresses
messages.forEach(function(message) {
message.forEach(function(d) {
emailArray.push(d.getFrom(),d.getTo());
});
});
// de-duplicate the array
var uniqueEmailArray = emailArray.filter(function(item, pos) {
return emailArray.indexOf(item) == pos;
});
var cleanedEmailArray = uniqueEmailArray.map(function(el) {
var name = "";
var email = "";
var matches = el.match(/\s*"?([^"]*)"?\s+<(.+)>/);
if (matches) {
name = matches[1];
email = matches[2];
} else {
name = "N/A";
email = el;
}
return [name,email];
}).filter(function(d) { // remove filter param if you don't want to remove away any email adress from the array
if (
d[1] !== "levent@able3ventures.com" &&
d[1] !== "noreply@able3ventures.com" &&
d[1] !== "able3@able3ventures.com"
) {
return d;
}
});
}