Sending Email from List View

Jithin2
Tera Contributor

Hi All,

I would like to send an email out from the list view? Is this possible?

I will explain a little more.

Scenario:

Lets assume I am running a filter on Incident table. It will return a set of Records and all of these Incidents returned will have an "assigned to". I would like to send a notification to all the "assigned to" users.

I hope we may have to use a "List Choice" UI Action here. Any body has any idea in this regard?

Your help will be very much appreciated.

Regards,

J

1 ACCEPTED SOLUTION

jagarnathn
Tera Expert

Hi Jithin,



You can do this via a scheduled job which needs to run based on your preference..



you should use   addEncodedQuery('query') to get the desired   records.   Once   you executed the query, you need to have an event to trigger   for   notifications.



for Example



var gr= new GlideRecord('incident');


gr.addEncodedQuery('active=true');


gr.addNotnullQuery('assigned_to');


gr.query();


while(gr.next()){


gs.eventQueue('eventname',gr, gr.assigned_to,"");


}



The same thing you can achieve it via List UI action as well.



Regards,


Jagarnath


View solution in original post

6 REPLIES 6

Chuck Tomasi
Tera Patron

Hi Jithin,



You are on the right track. A list choice UI action is what you will need to go through each record and retrieve the information to send the assigned_to a message. (You may want to consider de-duplicating entries in that list so the same person doesn't get 10 messages - or perhaps that's what you want.)



I don't use list choice UI actions all that often. When in doubt, use an existing UI action of the same type as a template, make a copy, and modify to your needs.



UI Actions - ServiceNow Wiki


Jithin2
Tera Contributor

Hi ctomasi,


Thanks for the suggestion. Have you implemented anything like this before. I couldn't find any related OOB UI Actions.



Regards,


Jithin


take the entry from the list action for selected records, and pass them to a script include,.



now for each object(glibe object to incident) you have to make perform an insert operation on sys_email table


something like this



var gr = new GlideRecord('sys_email');


  gr.initialize();


  gr.subject = 'blah blah'


  gr.mailbox.setDisplayValue('Outbox');


  gr.body = 'blah blah';


  gr.content_type = 'multipart/mixed';


  gr.state='ready';


  gr.target_table = 'incident';


gr.type='send-ready';


  gr.uid='N/A';



  gr.recipients = inc.user.email;


  gr.setNewGuid();


  gr.insert();


-Anurag

Hi Anurag,



Thanks for the reply. Can you please make your point a little more clear?



Regards,


Jithin