From d0d0e923b921532c77ff1d3ee7154c68310795ff Mon Sep 17 00:00:00 2001 From: Kart-19 <92006241+Kart-19@users.noreply.github.com> Date: Mon, 27 Oct 2025 20:52:47 +0530 Subject: [PATCH 1/2] Add files via upload Send Email On Form for every Record --- .../EmailScript.js | 19 +++ .../Notification.js | 22 ++++ .../Send Email On Form Incident/UIAction.js | 18 +++ .../UIPage_Html.html | 109 ++++++++++++++++++ .../UIPage_ProcessingScript.js | 13 +++ 5 files changed, 181 insertions(+) create mode 100644 Client-Side Components/UI Pages/Send Email On Form Incident/EmailScript.js create mode 100644 Client-Side Components/UI Pages/Send Email On Form Incident/Notification.js create mode 100644 Client-Side Components/UI Pages/Send Email On Form Incident/UIAction.js create mode 100644 Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_Html.html create mode 100644 Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_ProcessingScript.js diff --git a/Client-Side Components/UI Pages/Send Email On Form Incident/EmailScript.js b/Client-Side Components/UI Pages/Send Email On Form Incident/EmailScript.js new file mode 100644 index 0000000000..7890cfcd32 --- /dev/null +++ b/Client-Side Components/UI Pages/Send Email On Form Incident/EmailScript.js @@ -0,0 +1,19 @@ +// 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 + + +(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template, + /* Optional EmailOutbound */ + email, /* Optional GlideRecord */ email_action, + /* Optional GlideRecord */ + event) { + + + // 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 + + var obj = JSON.parse(event.parm2); + email.addAddress("cc", obj.cc); + email.setSubject(obj.subject); + + template.print("
Hi Team,

Details are :

" + obj.body); + +})(current, template, email, email_action, event); \ No newline at end of file diff --git a/Client-Side Components/UI Pages/Send Email On Form Incident/Notification.js b/Client-Side Components/UI Pages/Send Email On Form Incident/Notification.js new file mode 100644 index 0000000000..ac5b15c10b --- /dev/null +++ b/Client-Side Components/UI Pages/Send Email On Form Incident/Notification.js @@ -0,0 +1,22 @@ +/* +Notificaiton for this proble + +Table : Incident (incident) + +When to Send +Send when - Event is fried +Event name - SendEamilInForm + +Who will receive +Event parm 1 contains recipient - True + +What it will contain +// This will hold the email script which we use to populate the subjec and the body. +Message HTML - ${mail_script:IncidentFormScript} +Email template - Unsubscribe and Preferences +Content type - HTML only + +*/ + +// Name of the Email Script will be populated when the notification has been triggered. +${mail_script:IncidentFormScript} \ No newline at end of file diff --git a/Client-Side Components/UI Pages/Send Email On Form Incident/UIAction.js b/Client-Side Components/UI Pages/Send Email On Form Incident/UIAction.js new file mode 100644 index 0000000000..709e766e23 --- /dev/null +++ b/Client-Side Components/UI Pages/Send Email On Form Incident/UIAction.js @@ -0,0 +1,18 @@ +// 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 + +/* +Table- Incident (incident) +Form button - True +Client -True +Show Update - True +Onclick - Function name (sendEmail) + + + +*/ + function sendEmail(){ + var modalT = new GlideModal("SendEmailEvent", false, 1200); + modalT.setTitle("Send Email"); + modalT.setPreference("sysparm_sys_id", g_form.getUniqueValue()); + modalT.render(); + } \ No newline at end of file diff --git a/Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_Html.html b/Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_Html.html new file mode 100644 index 0000000000..2d47ac6adc --- /dev/null +++ b/Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_Html.html @@ -0,0 +1,109 @@ + + + + + + + + + + + + + var gr_inc = new GlideRecord('incident'); + gr_inc.addQuery('sys_id', '${jvar_sysId}'); + gr_inc.query(); + gr_inc; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_ProcessingScript.js b/Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_ProcessingScript.js new file mode 100644 index 0000000000..31d02504bc --- /dev/null +++ b/Client-Side Components/UI Pages/Send Email On Form Incident/UIPage_ProcessingScript.js @@ -0,0 +1,13 @@ +// Getting the value from the HTML and the make the body and trigger the event for further process. + +var obj={}; +obj.body = body.toString(); +obj.cc = cc.toString(); +obj.subject = subject.toString(); + +// Event Trigger and passing the paramenters +/* +Parm 1 : will have the to receipient +Parm 2 : will have the cc, subject and body +*/ +gs.eventQueue("SendEmailInForm",current,to,JSON.stringify(obj)); \ No newline at end of file From f44c5d4614b2311e87e49e5470770b54b237474e Mon Sep 17 00:00:00 2001 From: Kart-19 <92006241+Kart-19@users.noreply.github.com> Date: Mon, 27 Oct 2025 20:57:14 +0530 Subject: [PATCH 2/2] Add Readme for Send Email On Form Incident feature --- .../Send Email On Form Incident/Readme.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Client-Side Components/UI Pages/Send Email On Form Incident/Readme.md diff --git a/Client-Side Components/UI Pages/Send Email On Form Incident/Readme.md b/Client-Side Components/UI Pages/Send Email On Form Incident/Readme.md new file mode 100644 index 0000000000..78dfaffa32 --- /dev/null +++ b/Client-Side Components/UI Pages/Send Email On Form Incident/Readme.md @@ -0,0 +1,39 @@ +Send Email On Form for every Record + +Script Type: UI Action, Table: incident, Form button: True, Client: True, Show update: True, OnClick: functionName() + +Script Type: UI Page Category: General + +Script Type: Email Script + +Event Registry : Table: incident, Fired by: UI Page, Event Name: SendEmailInForm + +Notification : Table: incident, Type: EMAIL, Category: Uncategorized, + +Goal: To Send Email on Form Directly by population some field and then customize the body and trigger it. + +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. + +UIAction_INC_fomr + + +UI Page - This will have 5 components +1. To Caller +2. CC +3. Subject +4. Body +5. Send button + +UI Page Email template + + + +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. + +Notification_Contains +Notification_Receive +Notification1 + + + +Email Preview