We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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

8 REPLIES 8

Yes. in the button's script include, you can do sth like : gliderecord the table/record you want, get the current value of the field where you are storing the value, if it is empty, write 1; else get the value of the field and add one. set this new value to the field. In this way you get how many times the button is clicked/ how many times it is previewed.

I have emails in SOW workspace. when I open this email it would directly opens preview email record. that's the issue I can't able to track the count
sanjay02_0-1749554535130.png

sanjay02_1-1749554639259.png

 

 

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

ohh i get it, i thought you clicked a button to preview the email, as we were discussing in this thread, but you only click the created date right? i would suggest to open a new discussion where you ask about this thing specifically, but right now i cant think of anything to achieve that. Sorry

Julia12
Tera Expert

Where to put the script to? In the regular UI Action workspace session? Need to create a button in workspace to preview emails too.