I have a requirement for a resouce_plan table when a correction in the man-hour occurs send notify.
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 10:43 PM
When a correction in the man-hours(Planned hours) occurs at the time the status is allocated, it should trigger a notification to the employee, indicating that the man-hours(Planned hours) have been corrected. This notification can be initiated by pressing a button(Send notification).
I have created button "Send Notification" but how to trigger notification using UI action button.
- 188 Views
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 10:58 PM
hi @Community Alums
Here are the steps that might help you
1- open the UI action button that you have created
2- Onclick - sendNotification(current)
script-
function sendNotification(current) {
var assignedTo = current.assigned_to.getDisplayValue(); // Replace 'assigned_to' with your actual field name
var plannedHours = current.planned_hours; // Replace 'planned_hours' with your actual field name
// Construct the notification message
var message = "The planned hours for this record have been corrected to " + plannedHours + " hours.";
// Create a notification record
var notification = new GlideRecord('sys_notification');
notification.newRecord();
notification.addEncodedQuery('type=sn_task_notification&task=' + current.sys_id); // Replace 'sn_task_notification' with your desired notification type
notification.short_description = "Planned Hours Corrected";
notification.urgency = 'INFO';
notification.recipient = assignedTo;
notification.body = message;
notification.insert();
g_form.flashMessage('success', 'Notification sent to ' + assignedTo + '.');
}