@@ -5,9 +5,32 @@ function contactPartner() {
5
5
const docId = SpreadsheetApp . getActiveSpreadsheet ( ) . getId ( ) ;
6
6
const sheetLink = `https://docs.google.com/spreadsheets/d/${ docId } /edit` ;
7
7
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.` ;
9
9
const recipient = "[email protected] " ;
10
10
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
+
11
34
// Send the email using MailApp service
12
35
MailApp . sendEmail ( {
13
36
to : recipient ,
@@ -16,9 +39,8 @@ function contactPartner() {
16
39
} ) ;
17
40
18
41
// Display a message to the user
19
- const ui = SpreadsheetApp . getUi ( ) ;
20
42
ui . alert ( `Email Sent! \n\nDoiT may request viewer access to assist you.` ) ;
21
-
43
+
22
44
// Log confirmation
23
45
console . log ( "Email Sent successfully." ) ;
24
46
} catch ( error ) {
@@ -27,18 +49,10 @@ function contactPartner() {
27
49
28
50
// Display troubleshooting suggestions
29
51
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." ) ;
38
54
} 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] ." ) ;
42
56
}
43
57
}
44
58
}
0 commit comments