Project - Notification -Create a Button which on click redirects to that sepcific approval.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a notification which runs when the project state is Screening and Approval is requested (Here the approval will also be assigned to - to whom ever the project is assigned) .and it is sent to Assigned to Now on this notification I have to create a Button called 'View Approval Task' which on click it should redirect to that
Specific Approval task Something like the below image
I did tried by creating a below mail script but it's not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
This is the corrected code you need to use. In the version you provided earlier, the link variable was not being populated. We need to pass a redirection link to the approval record. That’s why, in this script, I’m passing the sys_id of the approval record to generate the correct URL.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email,
/* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Get the instance URL (used to open the approval record in the native UI)
var instanceURL = gs.getProperty('glide.servlet.uri');
if (instanceURL.endsWith('/')) {
instanceURL = instanceURL.slice(0, -1);
}
// Button/Link style settings
var message = 'View Approval Task';
var backgroundColor = 'background-color: #152456;';
var color = 'color: #ffffff; font-weight: bold;';
var fontSize = 'font-size: 12px;';
var fontBold = 'font-weight: bold;';
var fontFamily = 'font-family: trebuchet ms, geneva;';
var textDecoration = 'text-decoration: none; border-radius: 2px; text-align:center;';
var display = 'display: inline-block;';
var padding = 'padding: 10px 20px;';
// Fetch the most recent pending approval record
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', current.sys_id);
app.addQuery('state', 'requested');
app.orderByDesc('sys_created_on');
app.query();
if (app.next()) {
var link = instanceURL + '/sysapproval_approver.do?sys_id=' + app.sys_id;
template.print('<a href="' + link + '"');
template.print(' style="' + backgroundColor + color + fontSize + fontBold + fontFamily + textDecoration + display + padding + '">');
template.print(message);
template.print('</a>');
}
})(current, template, email, email_action, event);
Please refer to the image below:
on clicking the ‘View Approval Task’ button I will be redirected to approval record in native UI , can see in below image: