Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

preview email button in workspace

jennv
Mega Guru

Hello everyone, i need to do a button in workspace to preview the email related to current case. I get the sys id of the email using glide ajax, but then i dont know how to show the email. i guess i should use g_modal and then use the ootb ui page preview_email, but im not sure how to achieve this. 

the preview of email doesnt have an own link either, that i couldve used. 

Any suggestions please?

1 ACCEPTED SOLUTION

Hey i actually solved it. The code i used to show the email:

  var resultObj = JSON.parse(response);
            if (resultObj.email_sysid) { //email_sysid is the sys id of the email in sys_email table that i get from Script invlude

                var url = '/preview_email.do?sysparm_id=' + encodeURIComponent(resultObj.email_sysid);

                g_modal.showFrame({
                    title: "Preview e-mail",
                    url: url,
                    size: 'lg', // 'sm', 'md', 'lg'
                    height: 800,
                    autoCloseOn: 'URL_CHANGED',
                    callback: function(ret, data) {
                        if (ret) {
                            //console.log('Modal confirmed:', data);
                        }
                    }
                });



            } else {
                g_modal.richText("Preview e-mail", "<b>There are no emails related to this case.</b>", callback, {
                    cancelTitle: "Cancel",
                })
            }

View solution in original post

7 REPLIES 7

carmen_man
ServiceNow Employee
ServiceNow Employee

I need the same too, anyone can shine some light on this subject?

Hey i actually solved it. The code i used to show the email:

  var resultObj = JSON.parse(response);
            if (resultObj.email_sysid) { //email_sysid is the sys id of the email in sys_email table that i get from Script invlude

                var url = '/preview_email.do?sysparm_id=' + encodeURIComponent(resultObj.email_sysid);

                g_modal.showFrame({
                    title: "Preview e-mail",
                    url: url,
                    size: 'lg', // 'sm', 'md', 'lg'
                    height: 800,
                    autoCloseOn: 'URL_CHANGED',
                    callback: function(ret, data) {
                        if (ret) {
                            //console.log('Modal confirmed:', data);
                        }
                    }
                });



            } else {
                g_modal.richText("Preview e-mail", "<b>There are no emails related to this case.</b>", callback, {
                    cancelTitle: "Cancel",
                })
            }

carmen_man
ServiceNow Employee
ServiceNow Employee

Thanks for sharing @jennv 

sanjay02
Tera Guru

Hi @jennv ,
Is it possible to track how many times an email is previewed and show that count in a field?

If my response helped you, please click “Accept as Solution”. Your recognition motivates me to keep sharing knowledge.
Cheers,

Sanjay J.