Custom button on Service Portal to send email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 08:08 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 09:28 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2020 05:31 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2020 03:50 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2020 06:38 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2020 08:50 AM
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