Send a email via Service Portal

Nancy8
Giga Contributor

I have one requirement below

There is "Copy My Request" on "Purchase Software" catalog item form in our IT Service Portal.  After the user submit  "Purchase Software" catalog item form and then when the user clicks a button -"Copy My Request" button, an email notification will be sent out.   

I am new to Service Portal, I don't know how to implement email notification part in Service Portal,  can any expert give some direction?

3 REPLIES 3

johansec
Tera Guru

So I am assuming that the user is filling out the form on the sc_cat_item and then submitting the form.

After that what page are they going to?

Is this a button you created in a widget or is this an ui action? 

 

The button will most likely have to trigger an email notification via event. I would configure the notification to trigger based off an event using gs.eventQueue(). This can be done in the server script of the widget or it can be done in an ui action. 

Nancy8
Giga Contributor

This button will be created in a widget so I can create click function in Client Script of Widget, but I don't know how to trigger to execute "gs.eventQueue()" in server script from client script of widget 

So a widget has a server script and a client script. One button click there are a couple ways to do this. 

  1. If the button click updates some field in the table you could avoid this all together and trigger the notification based on your changes to a record. For example a notification with conditions Closed Notes Changes  (This will be much easier for you) I dont know your requirements though. 
  2. If not then in the client script when the button is clicked you can use c.server.update(). This will perfrom an ajax call back the the serverscript with all the data in the "data" object to the server as an input object. 
    1. So in your server script you can put if(input){console.log('I POSTED BACK')}
    2. This way you can ensure your button click successfully triggered the ajax call back to the server. 
    3. Once you have this down you can replace the log with an event to trigger an email. 
    4. The syntax for this is gs.eventQueue('event.name', GlideRecord, parm1, parm2);
      1. There are plenty examples out there of people doing this from business rules and I assume this would be the same 
      2. https://community.servicenow.com/community?id=community_question&sys_id=6a228f6ddb98dbc01dcaf3231f96196f
    5. So Event name will be an event you create on the table sysevent_register
    6. Glide Record is the current record you are working with
    7. Param1 and param2 are for you to use as you would like. One of the parameters are used for who to send this notification to. The other can be used however you would like.

 

Good luck