Hello, try this:
1. Open a mailto: link for the selected contact's email address.
2. Create a new record in the Outreach table, linking it to the selected contact and adding a timestamp.
let contactTable = base.getTable("Contacts");
let outreachTable = base.getTable("Outreach");
let contactRecord = await input.recordAsync("Select a contact", contactTable);
if (!contactRecord) {
output.text("No contact selected. Exiting script.");
return;
}
let email = contactRecord.getCellValue("Email");
let fullName = contactRecord.getCellValue("Full Name");
if (!email) {
output.text("The selected contact does not have an email address. Exiting script.");
return;
}
let mailtoLink = `mailto:${email}`;
output.text(`Opening email client for: ${email}`);
window.open(mailtoLink);
await outreachTable.createRecordAsync({
"Full Name": [{ id: contactRecord.id }] (link the record to the selected contact)
"Date/Time": new Date().toISOString() (Add a timestamp)
});
output.text(`Outreach record created for ${fullName}.`);
If mailto links fail to open directly from the script due to restrictions, you can display the link as text for manual use.
Also, ensure the field names (Email, Full Name, and Date/Time) match your actual table setup.
Let me know if you need more detailed instructions or explanations. Hope it helps.
Hello,
нere’s how you can achieve this:
1. Open a mailto: link using the selected contact's email address.
2. Add a new entry in the Outreach table, linking it to the selected contact and recording the current timestamp.
let contactTable = base.getTable("Contacts");
let outreachTable = base.getTable("Outreach");
Prompt the user to select a contact from the Contacts table - let contactRecord = await input.recordAsync("Select a contact", contactTable);
Exit the script if no contact is chosen:
if (!contactRecord) {
output.text("No contact selected. Script terminated.");
return;
}
Retrieve the email and full name of the chosen contact:
let email = contactRecord.getCellValue("Email");
let fullName = contactRecord.getCellValue("Full Name");
Exit if the contact does not have an email address:
if (!email) {
output.text("The selected contact lacks an email address. Script terminated.");
return;
}
Сreate and open the mailto: link in the default email client:
let mailtoLink = `mailto:${email}`;
output.text(`Opening email client for: ${email}`);
window.open(mailtoLink);
Create a new record in the Outreach table, linking it to the selected contact and adding the current timestamp:
await outreachTable.createRecordAsync({
"Full Name": e{ id: contactRecord.id }], // Associate with the contact.
"Date/Time": new Date().toISOString() // Record the timestamp.
});
output.text(`Successfully created an outreach record for ${fullName}.`);
If `mailto:` links don’t open directly due to restrictions, display the link for manual use.
Also, ensure that your field names (Email, Full Name, and Date/Time) align with your actual table configuration.
Let me know if you need further clarification or guidance.