Custom button on Service Portal to send email

Bruler1230
Tera Expert

Hello,

I have created a custom button in a widget on the service portal. When that button is clicked, i need to send an email to the assignemnt group that the ticket is currently assigned to. Has anyone done this or have any examples how i can generate an email when the button is clicked? I have created a client email template to use, but not quite sure how to initiate the email. I beleive it has something to do with the email client. Any help is appreciated.

Thanks

14 REPLIES 14

You can control this in condition of your widget which has this button.

You can query sys_email table for email sent timestamp and hide button based on date difference between current date and email sent date on from sys_email table.

 

Regards,

Sachin

Thanks...so for the query..

var lastEmail = new GlideRecord('sys_email');

lastEmail.query('sys_created_on', ??);  <- what value should i be looking for here?

lastEmail.query();

 

gs.eventQueue('send.email', gr, gr.approvers.getDisplayValue());

 

Any suggestions? Thanks

Use below query

var lastEmail = new GlideRecord('sys_email');

lastEmail.addEncodedquery('mailbox=sent^sys_created_onRELATIVEGE@dayofweek@ago@7');

lastEmail.query();

while(lastEmail.next()){
 

gs.eventQueue('send.email', gr, gr.approvers.getDisplayValue());

}

 

Regards,

Sachin

Thanks...so if i do it this way, if there are multiple emails, then when while(lastEmail.next()) executes, the event will fire for each individual instance of that email, right? How would only go by the most recent one?

Use below code to find out most recent one

 

var lastEmail = new GlideRecord('sys_email');

lastEmail.addEncodedquery('mailbox=sent^sys_created_onRELATIVEGE@dayofweek@ago@7');

lastEmail.orderBy('sys_created_on');

lastEmail.query();

while(lastEmail.next()){
 

gs.eventQueue('send.email', gr, gr.approvers.getDisplayValue());

}

 

Regards,

Sachin