Find Free Medical software of Best Pharmacy software by Gsmetrix that is a cloud based ERP system which is built for pharmacy industry. Gsmetrix ERP is free for download & evaluation purposes.
Category:Free ERP softwareQ:
Open Google Sheets based on the last name of a contact
I'm trying to make a system where Google Sheets opens the sheet based on the last name of a contact in my Gmail. I'm using the script below to generate the link and it works well. My problem is that it has to look for the last name in the contacts and open the appropriate sheet based on the last name.
The problem is that, when I make a new contact with a different last name, the script still opens the sheet based on the last name of the first contact.
Any help is appreciated.
I have a Google script:
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: 'My Open'}];
ss.addMenu("My Open", menuEntries);
}
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[1];
sheet.showSheet();
}
The button that generates the link
function onOpen() {
var html = 'My Open';
GmailApp.sendEmail('example@gmail.com', 'Open Sheet', 'Hi,
The last name of the contact is:'+ ContactsApp.getContactByEmail('example@gmail.com').getLastName() + '
Thanks!', {htmlBody: html});
}
The Google Script
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets be359ba680
Related links:
Comments