how to send ui page user input data to email as notification

srkuraku
Kilo Contributor

Developers team,

I have created UI page through UI action button as follows. When user click on HPI button on Incident form, the following UI page opens.

If user enters the data manually and   click on OK button, all   manually enter data should be delivered to email as a notification below.   How could I achieve this following email notification   format?

PS: UI page form fields are manually added and not Incident fields or System fields.

"Current Status (Executive Summary 😞 Date and Time: 9/22/2016 07:46:00 (UTC)
Incident State: Active
Retests are passing and the NOC has received improved emails for each. Dashboards and Egraph show no traffic loss in Atlanta, In addition, we are also seeing 5xx errors on multiple ADN servers in the North American Region and have received two customer complaints isolated to Level3 circuits in CPM. AppSupport HTTP has been engaged to investigate.

Bridge Info: 1-866--99940=22

Ticket Number: INC0000018

Short description: Sales forecast spreadsheet is READ ONLY

Priority: 1 - Critical

Business Area Impact: Network

Location of Impact: boston

Incident Timeline: 07:10:00 (UTC) NOC started to receive mu

Lead on Floor: INC0000008

Group of Representatives: Sis

Next Expected Update: 20 minutes"

find_real_file.png

15 REPLIES 15

Hello Chetan,



Thank you very much. My HTML XML looks ldifferent than yours. Is anything can I change from side, Should I go directly with it?



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:ui_form>


  <g:evaluate var="jvar_short_text"


      expression="RP.getWindowProperties().get('short_text')" />


  <g:evaluate var="jvar_comments_text"


      expression="RP.getWindowProperties().get('comments_text')" />


  <g:evaluate var="jvar_incident_number"


      expression="RP.getWindowProperties().get('number')" />


        <input type="hidden" name="sys_id" value="${jvar_gr.getValue('sys_id')}"/>


  <input type="hidden" name="number" value="${jvar_incident_number}"/>



   


    <table align="center" width="100%" cellpadding="4" cellspacing="20" border="0" >



<tr>


<td ><label for="Ticket Number">Ticket Number:</label></td>


<td ><input name="Ticket Number" id="Ticket Number" type="text"/></td>


<td ><label for="Bridge Info">Bride Info:</label></td> <td>


<input name="Bridge Info" id="Bridge Info" type="text"   /></td>


</tr>


  <tr><td><br></br></td></tr>



<tr>


<td><label for="Date Time">Date Time:</label></td>


<td><input name="Date Time" id="Date Time" type="text" /></td>


<td><label for="Business Area Impacted"> Business Area Impacted:</label></td> <td>


<input name="Business Area Impacted" id="Business Area Impacted" type="text" /></td>


</tr>




<tr><td><b>Incident Timeline (Milestones):</b></td><td><textarea name = "timeline" id="timeline" maxlength="2000" rows="4" cols="50" /></td></tr>


     


<tr><td><br></br></td></tr>




      <tr><td><b>Excutive Summary (Current Status):</b></td><td><textarea name = "excutive" id="excutive" maxlength="2000" rows="4" cols="50" /></td></tr>


     



        <tr>


            <td colspan="2">


            </td>


        </tr>


        <!--tr id="dialog_buttons">


              <td colspan="2" align="left">


                    <g:dialog_buttons_ok_cancel ok="return hpiCommunication()" ok_type="button" cancel_type="button" />



              </td>


        </tr-->


  <tr><td>


  <g:dialog_button id="ok_button" type="submit" style="">${gs.getMessage('OK')}</g:dialog_button>  


        <g:dialog_button id="cancel_button" type="submit" onclick="GlideDialogWindow.prototype.locate(this).destroy(); return false">${gs.getMessage('Cancel')}


  </g:dialog_button></td></tr>  


  </table>


</g:ui_form>


</j:jelly>




You want me add anything in UI Action:???



function openEmailVIPDialog() {


    var comments_text = g_form.getValue("comments");


    var short_text = g_form.getValue("short_description");


    var inc_number = g_form.getValue("number");


    var dialog = new GlideDialogWindow("SendEmailDialog");


    dialog.setTitle("HPI Communication");


    dialog.setSize(984, 729);


    dialog.setPreference("number",inc_number);


    dialog.setPreference("comments_text", comments_text);


    dialog.setPreference("short_text", short_text);


    dialog.render();


}


Hi Sivaraju ,



HTML shared seems different from the UI page screenshot in your post .


In your HTML there are only 6 fields i.e.


  1. Current Status (Executive Summary )
  2. Date Time:
  3. Bride Info:
  4. Ticket No.
  5. Business Area Impacted:
  6. Incident Timeline (Milestones):


I can't find the use of values comments and short description that you've fetched using (UI page parameters) :


  <g:evaluate var="jvar_short_text"


      expression="RP.getWindowProperties().get('short_text')" />


  <g:evaluate var="jvar_comments_text"


      expression="RP.getWindowProperties().get('comments_text')" />



I've updated the HTML and processing script keeping aforementioned 6 fields in mind :



HTML :


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:ui_form>


  <g:evaluate var="jvar_short_text"


      expression="RP.getWindowProperties().get('short_text')" />


  <g:evaluate var="jvar_comments_text"


      expression="RP.getWindowProperties().get('comments_text')" />


  <g:evaluate var="jvar_incident_number"


      expression="RP.getWindowProperties().get('number')" />


        <input type="hidden" name="sys_id" value="${jvar_gr.getValue('sys_id')}"/>


  <input type="hidden" name="number" value="${jvar_incident_number}"/>



 


    <table align="center" width="100%" cellpadding="4" cellspacing="20" border="0" >



<tr>


<td ><label for="Ticket Number">Ticket Number:</label></td>


<td ><input name="ticket_number" id="ticket_number" value="${jvar_incident_number}" type="text"/></td>


<td ><label for="Bridge Info">Bride Info:</label></td> <td>


<input name="bridge_info" id="bridge_info" type="text"   /></td>


</tr>


  <tr><td><br></br></td></tr>



<tr>


<td><label for="Date Time">Date Time:</label></td>


<td><input name="date_time" id="date_time" type="text" /></td>


<td><label for="Business Area Impacted"> Business Area Impacted:</label></td> <td>


<input name="business_area_impacted" id="business_area_impacted" type="text" /></td>


</tr>




<tr><td><b>Incident Timeline (Milestones):</b></td><td><textarea name = "timeline" id="timeline" maxlength="2000" rows="4" cols="50" /></td></tr>


   


<tr><td><br></br></td></tr>




      <tr><td><b>Excutive Summary (Current Status):</b></td><td><textarea name = "executive" id="executive" maxlength="2000" rows="4" cols="50" /></td></tr>


   



        <tr>


            <td colspan="2">


            </td>


        </tr>


        <!--tr id="dialog_buttons">


              <td colspan="2" align="left">


                    <g:dialog_buttons_ok_cancel ok="return hpiCommunication()" ok_type="button" cancel_type="button" />



              </td>


        </tr-->


  <tr><td>


  <g:dialog_button id="ok_button" type="submit" style="">${gs.getMessage('OK')}</g:dialog_button>


        <g:dialog_button id="cancel_button" type="submit" onclick="GlideDialogWindow.prototype.locate(this).destroy(); return false">${gs.getMessage('Cancel')}


  </g:dialog_button></td></tr>


  </table>


</g:ui_form>


</j:jelly>



Processing Script :


var HPITemplate ='';


HPITemplate += "Current Status (Executive Summary 😞 "+executive+"\n";


HPITemplate += "Date Time: "+date_time+"\n";


HPITemplate += "Bride Info: "+bridge_info+"\n";


HPITemplate += "Ticket No. : "+ticket_number+"\n";


HPITemplate += "Business Area Impacted: "+business_area_impacted+"\n";


HPITemplate += "Incident Timeline (Milestones): "+timeline+"\n";  



gs.addInfoMessage('event Queue...');


gs.eventQueue("emailVIPEvent", current, gs.getUserID(), HPITemplate);



//response.sendRedirect('incident.do?sys_id='+sys_id);


response.sendRedirect('incident_list.do?sysparm_userpref_module=b55fbec4c0a800090088e83d7ff500de&sysparm_query=active=true^EQ&active=true');


gs.addInfoMessage('Mail has been sent.');




And in the body of the email notification :


<mail_script>


event.parm2     // HPI Template data fetched from UI page .


</mail_script>



Please have a look into this .



PS - Please mark Helpful, Like, or Correct Answer if applicable.


Thanks,


Chetan


Chetan Sondhi
Kilo Sage

Hi Sivaraju ,



Use ${event.parm2} in Email body .



find_real_file.png



I've tried this and it worked for me at my end .



Event Log :



find_real_file.png



Email sent out :



find_real_file.png



Try this and let me know if it worked .



PS - Please mark Helpful, Like, or Correct Answer if applicable.


Thanks,


Chetan


Hi chetan,



I tried and I got weird problem now, When I click on OK button, it got struck .Please login into my personal instance..check this out pls



https://dev24248.service-now.com/navpage.do   user:admin   pasword: admin



names as listed in the instance



UI action name : HPI


UI page name SendEmailDialog


Event Name : emailVIPEvent


Email Notification Name:



Thanks very much in advance


Okay ,I'll make changes to it and will let you know .



Thanks,


Chetan