Skip to content

Commit f0dc736

Browse files
committed
Update getHelp.gs
1 parent ef958aa commit f0dc736

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

getHelp.gs

+28-14
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,32 @@ function contactPartner() {
55
const docId = SpreadsheetApp.getActiveSpreadsheet().getId();
66
const sheetLink = `https://docs.google.com/spreadsheets/d/${docId}/edit`;
77
const subject = `Assistance Request - ${userEmail}`;
8-
const body = `Hi DoiT Team,\n\n${userEmail} has requested assistance with the Security Checklist for Workspace Admins. Please do your best to help them. \n\nA link to the customer's Security Checklist is included below: \n${sheetLink}`;
8+
let body = `Hi DoiT Team,\n\n${userEmail} has requested assistance with the Security Checklist for Workspace Admins. Please do your best to help them.`;
99
const recipient = "[email protected]";
1010

11+
// Create a radio button prompt
12+
const ui = SpreadsheetApp.getUi();
13+
const response = ui.alert(
14+
'Send Email',
15+
'Are you sure you want to send an email to DoiT International to request assistance?',
16+
ui.ButtonSet.YES_NO
17+
);
18+
19+
if (response !== ui.Button.YES) {
20+
return; // User canceled, do nothing
21+
}
22+
23+
// Display a radio button prompt
24+
const includeLink = ui.alert(
25+
'Include Link to Spreadsheet',
26+
'Include a link to your spreadsheet in the email?',
27+
ui.ButtonSet.YES_NO
28+
);
29+
30+
if (includeLink === ui.Button.YES) {
31+
body += `\n\nA link to the customer's Security Checklist is included below: \n${sheetLink}`;
32+
}
33+
1134
// Send the email using MailApp service
1235
MailApp.sendEmail({
1336
to: recipient,
@@ -16,9 +39,8 @@ function contactPartner() {
1639
});
1740

1841
// Display a message to the user
19-
const ui = SpreadsheetApp.getUi();
2042
ui.alert(`Email Sent! \n\nDoiT may request viewer access to assist you.`);
21-
43+
2244
// Log confirmation
2345
console.log("Email Sent successfully.");
2446
} catch (error) {
@@ -27,18 +49,10 @@ function contactPartner() {
2749

2850
// Display troubleshooting suggestions
2951
const ui = SpreadsheetApp.getUi();
30-
if (
31-
error.message.includes(
32-
"Required permissions: https://www.googleapis.com/auth/userinfo.email",
33-
)
34-
) {
35-
ui.alert(
36-
"Error: You do not have permission to access user information. Please enable the required permission and try again.",
37-
);
52+
if (error.message.includes("Required permissions: https://www.googleapis.com/auth/userinfo.email")) {
53+
ui.alert("Error: You do not have permission to access user information. Please enable the required permission and try again.");
3854
} else {
39-
ui.alert(
40-
"Error sending email. Please check your internet connection and try again. If the problem persists, contact support at [email protected].",
41-
);
55+
ui.alert("Error sending email. Please check your internet connection and try again. If the problem persists, contact support at [email protected].");
4256
}
4357
}
4458
}

0 commit comments

Comments
 (0)