Skip to content

Commit 1ed7055

Browse files
authored
Add files via upload
Send Email On Form for every Record
1 parent 96a976c commit 1ed7055

File tree

13 files changed

+206
-0
lines changed

13 files changed

+206
-0
lines changed
14.1 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Email is been used to set the cc and subjed where we got from the UI Page and this will be attached to the Notification to run dymanically
2+
3+
4+
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
5+
/* Optional EmailOutbound */
6+
email, /* Optional GlideRecord */ email_action,
7+
/* Optional GlideRecord */
8+
event) {
9+
10+
11+
// In this we get the data in the 4th parameter so that we use the parm2 to get the object of data and the used in the certain purpose
12+
13+
var obj = JSON.parse(event.parm2);
14+
email.addAddress("cc", obj.cc);
15+
email.setSubject(obj.subject);
16+
17+
template.print(" <h5 style='margin: 0px;'>Hi Team,</h5><br><p>Details are : </p>" + obj.body);
18+
19+
})(current, template, email, email_action, event);
22.2 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Notificaiton for this proble
3+
4+
Table : Incident (incident)
5+
6+
When to Send
7+
Send when - Event is fried
8+
Event name - SendEamilInForm
9+
10+
Who will receive
11+
Event parm 1 contains recipient - True
12+
13+
What it will contain
14+
// This will hold the email script which we use to populate the subjec and the body.
15+
Message HTML - ${mail_script:IncidentFormScript}
16+
Email template - Unsubscribe and Preferences
17+
Content type - HTML only
18+
19+
*/
20+
21+
// Name of the Email Script will be populated when the notification has been triggered.
22+
${mail_script:IncidentFormScript}
88.3 KB
Loading
44.6 KB
Loading
31.8 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Send Email On Form for every Record
2+
3+
Script Type: UI Action, Table: incident, Form button: True, Client: True, Show update: True, OnClick: functionName()
4+
5+
Script Type: UI Page Category: General
6+
7+
Script Type: Email Script
8+
9+
Event Registry : Table: incident, Fired by: UI Page, Event Name: SendEmailInForm
10+
11+
Notification : Table: incident, Type: EMAIL, Category: Uncategorized,
12+
13+
Goal: To Send Email on Form Directly by population some field and then customize the body and trigger it.
14+
15+
Walk through of code: So to send the Email directly on each and every record there will be a UI Action which will help to populate the UI Page which we use some field to be populate in the UI Page directly to the particulat HTML content and these are the fields will be populate (Caller Email as the To and then Short Description as the Subjet of the Email) and othe field will be CC and Body which the user want to decide what data can be filled out and then send.
16+
17+
UI Page - This will have 5 components
18+
1. To Caller
19+
2. CC
20+
3. Subject
21+
4. Body
22+
5. Send button
23+
24+
Once the Send button has been triggered this will call the Processing Script where the event will trigger once this will call the Event Registry event("SendEmailInForm") which we use for this problem statment.Where the Notification will trigger when the Event is fried and then for the email content we uset the Email Script which dynamic content will be populated which we got from the UI page as the event parm2 and then will send the email to the respective caller.
25+
16.9 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This function will creat the model object and then route to the UI page which we configured to show the field details to fill by the user
2+
3+
/*
4+
Table- Incident (incident)
5+
Form button - True
6+
Client -True
7+
Show Update - True
8+
Onclick - Function name (sendEmail)
9+
10+
11+
12+
*/
13+
function sendEmail(){
14+
var modalT = new GlideModal("SendEmailEvent", false, 1200);
15+
modalT.setTitle("Send Email");
16+
modalT.setPreference("sysparm_sys_id", g_form.getUniqueValue());
17+
modalT.render();
18+
}

0 commit comments

Comments
 (0)