compose email window popup via Ui action

Ayushi Saxena
Tera Contributor

Looking for help to create UI Action which redirect the user on URL of email(Similar the way by clicking on three dot "...")  with the current sys id  via a UI Page. 

 


var sysId = g_form.getUniqueValue(); // Get current record sys_id
var url = 'https://xyz/email_client.do' +
'?sysparm_table=sn_shop_purchase_requisition' +
'&sysparm_sys_id=' + sysId +
'&sysparm_target=sn_shop_purchase_requisition' +
'&sys_target=sn_shop_purchase_requisition' +
'&sys_uniqueValue=' + sysId +
'&sys_row=0' +
'&sysparm_encoded_record=' +
'&sysparm_domain_restore=false' +
'&sysparm_stack=no';

window.open(url, '_blank'); // Open URL in new tab
}

 

 

 

1 ACCEPTED SOLUTION

KrishnaMohan
Giga Sage

Hi @Ayushi Saxena 
Please use below code in ui action and ui page
 UI Page :  compose_email
   

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="email_preview">
	<iframe src='email_client.do?sysparm_table=incident&amp;sysparm_sys_id=${sysparm_id}&amp;sysparm_target=incident&amp;sys_uniqueValue=${sysparm_id}&amp;sys_row=0&amp;sysparm_encoded_record=&amp;sysparm_domain_restore=false&amp;sysparm_stack=no' id='send_email_iframe' width='100%' overflow-y='hidden' overflow-x='auto' frameborder='0' title="${gs.getMessage('Preview Email')}" style="background-color: white"/>
</div>
</j:jelly>

 UI Page  : Client Script 

$j('#send_email_iframe').on('load', function() {
	adjustIFrameSize($j(this));
});
function adjustIFrameSize(iframe) {
    var height = 0;

    if (isMSIE9 || isMSIE10) {
        height = iframe.contents().find('body').outerHeight(true);
    } else {
        height = iframe.contents().height();
    }
	iframe.height(height);
	iframe.width(iframe.parent().width());
}

UI Action : create client type ui action and use composeEmail() function name

function composeEmail() {
    var sysId = g_form.getUniqueValue();
   // var msg = " Send Email";
    var sendEmail = new GlideModal("compose_email");
    //sendEmail.setTitle(msg);
    sendEmail.setWidth(800);
    sendEmail.setPreference('sysparm_id', sysId); //pass the sys_id;
    sendEmail.render();
}



Output : 

KrishnaMohan_0-1748277248935.png


If I helped you with your case, please click the Thumb Icon and mark as Correct.


Thanks and Regards
Krishnamohan

View solution in original post

3 REPLIES 3

KrishnaMohan
Giga Sage

Hi @Ayushi Saxena 
Please use below code in ui action and ui page
 UI Page :  compose_email
   

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="email_preview">
	<iframe src='email_client.do?sysparm_table=incident&amp;sysparm_sys_id=${sysparm_id}&amp;sysparm_target=incident&amp;sys_uniqueValue=${sysparm_id}&amp;sys_row=0&amp;sysparm_encoded_record=&amp;sysparm_domain_restore=false&amp;sysparm_stack=no' id='send_email_iframe' width='100%' overflow-y='hidden' overflow-x='auto' frameborder='0' title="${gs.getMessage('Preview Email')}" style="background-color: white"/>
</div>
</j:jelly>

 UI Page  : Client Script 

$j('#send_email_iframe').on('load', function() {
	adjustIFrameSize($j(this));
});
function adjustIFrameSize(iframe) {
    var height = 0;

    if (isMSIE9 || isMSIE10) {
        height = iframe.contents().find('body').outerHeight(true);
    } else {
        height = iframe.contents().height();
    }
	iframe.height(height);
	iframe.width(iframe.parent().width());
}

UI Action : create client type ui action and use composeEmail() function name

function composeEmail() {
    var sysId = g_form.getUniqueValue();
   // var msg = " Send Email";
    var sendEmail = new GlideModal("compose_email");
    //sendEmail.setTitle(msg);
    sendEmail.setWidth(800);
    sendEmail.setPreference('sysparm_id', sysId); //pass the sys_id;
    sendEmail.render();
}



Output : 

KrishnaMohan_0-1748277248935.png


If I helped you with your case, please click the Thumb Icon and mark as Correct.


Thanks and Regards
Krishnamohan

Hi @KrishnaMohan ,
Thanks for the Reply. It's working fine. 
But one more thing i wanted to check 
Is it possible to close this white window popup automatically after clicking on send  like the same OOB email toggle(...dot>email) functionality works?

 

ss.png
I tried with the .destroy method. It works as well. 
but Actually first we need a way to know when the email has been sent and then calls GlideModal.get().destroy() to close the modal like that send button has been clicked then only it will be close automatically. 

 

SSSS.png

Can you please help me to do this.



Thanks and Regards
Ayushi







Ayushi Saxena
Tera Contributor

Hi @KrishnaMohan and all, 

 

I got to know, there is a method which we can use directly in UI action to implement the same email functionality,

function email() {
    emailClientOpenPop('table name');
}
 
 
Thanks & Regards,
Ayushi Saxena