How to Trigger an email from list view (multiple selection) UI actions

Community Alums
Not applicable

Hi Team,

Please suggest a best practice to trigger an email to users for the selected records from list view using UI actions.

 

Example : 

when multiple records selected and UI action 'Send reminder' should send email to the assigned to users for the selected records.

 

1. Please guide me how to use g_list.getChecked();  and  gs.eventQueue() 

g_list.getChecked(); - not working without onclick function

gs.eventQueue()  - not working inside onclick function

 

I tried creating incident table UI action , i can get the selected records using g_list.getChecked() but the event is not triggered using gs.eventQueue.

 

please suggest any other possible way to achieve this .

 

function sendmail() {    
    var getlist = g_list.getChecked();
    var sysidlist = getlist.split(',');
    var len = sysidlist.length;
    var i = 0;
    for (i; i < len; i++) {
        var gr = new GlideRecord('incident');        
        gr.addQuery('sys_id', sysidlist[i]);
        gr.query();
        if (gr.next()) {                    
            var gr1 = new GlideRecord('sys_user');
            gr1.addQuery('sys_id', a);
            gr1.query();
            if (gr1.next()) {   gs.eventQueue('email.user', current, gr.assigned_to);            
            } 
        }
    }
    }


3 REPLIES 3

Community Alums
Not applicable

gs.eventQueue() requires 4 parameters (actually 2 mandatory and 1 optional plus current object and user).

You have only 3 as i can see

@Community Alums  , 

Thanks for your reply

 

I tried 

gs.eventQueue('email.user', current, gr.assigned_to, ' ' );  also not working 

 

I need to use the onclick function to fetch the selected records from the list view and need to call the gs.eventQueue to trigger the notification for those selected records  from same UI action.

Please suggest is there any possible way to do this.

James Chun
Kilo Patron

Hi @Community Alums,

 

gs.eventQueue is a server-side script and you are trying to invoke it from the client side.

You would have to invoke AJAX to trigger the events.

 

BTW, did you consider using a scheduled job or Flow for this? Why not automate the reminders?

 

Cheers