Redirection for my ooo compose email ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 12:07 PM
Hi everyone
im using an OOO compose email ui action and it renders a client email template and generates the mail, so once i hit send email it is supposed to redirect me to the record but it stays in the same send email ui where email is generated and ready to send again, i want it to redirect to record instead if this, im not sure whats wrong here below is the script, i tried redirecting still not working and this is in workspace -
function onClick(g_form) {
if (g_form.getValue('approval_status') == '12') {
return;
}
var LEGACY_EMAIL_CLIENT_NAME = 'sn-email-editor',
SEISMIC_EMAIL_CLIENT_NAME = 'sn-email-client-wrapper',
EMAIL = 'sys_email',
DRAFT = 'sys_email_draft',
tValue = DRAFT;
// Get the list of renderers
var renderers = [];
if (ux_globals && ux_globals.presource['sn-workspace-content:snCustomRenderer']) {
renderers = ux_globals.presource['sn-workspace-content:snCustomRenderer'].data.GlideRecord_Query.sys_aw_renderer._results;
}
if (renderers.length > 0) {
// Filter out Email renderers
var renderMap = {};
renderers.filter(function(o) {
return o.table.value == EMAIL || o.table.value == DRAFT;
}).map(function(o) {
renderMap[o.table.value] = o.custom_renderer_tag.value;
});
// Determine the final value
if (!renderMap.hasOwnProperty(DRAFT))
tValue = EMAIL;
else {
if (!renderMap.hasOwnProperty(EMAIL))
tValue = DRAFT;
else if (renderMap[EMAIL] == LEGACY_EMAIL_CLIENT_NAME)
tValue = EMAIL;
}
}
// Generate the email first
g_aw.openRecord(tValue, '-1', {
parentTable: g_form.getTableName(),
parentSysId: g_form.getSysId(),
headerValue: getMessage("New Email"),
dirtyFields: g_form.serialize(true).map(function(field) {
return {
field: field.name,
value: field.value
};
})
});
// Wait a bit to ensure the email opens, then update the approval status
setTimeout(function() {
g_form.setValue('xxx', '12'); // Set the field to Disclosures Generated
g_form.save(); // Save the record
}, 2000); // Delay to ensure email template has time to load
}
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 12:30 AM
Hi @Its_Azar , I tried the OOB script and your script, both of them are redirecting to the record itself as expected (in workspace).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 12:11 PM
hey thanks for trying this, actually it works all fine until the client email template is called, so im calling a client email template and its generating but after sending mail it doesnt go back to the record, instead refreshes and stays in the send email page.
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India