Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions Client-Side Components/UI Pages/Edit Last WorkNotes/UIaction.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
//Enable client set to true
//Enter Onclick value as function name openEditLastCommentModal()
//Enter form button as true
/**
* Opens a modal to edit the last Work Notes or Additional Comments.
*
* @description
* This function is triggered by a form button (set to true),
* with client-side execution enabled. It opens a GlideModal
* using the UI macro "edit_worknotes_comments_inc" and sets
* the current incident sys_id as a preference for use within the modal.
*
* Usage:
* - Set Client = true
* - Set OnClick = openEditLastCommentModal()
* - Set Form Button = true
*/
function openEditLastCommentModal() {
// Create and configure the GlideModal
var dialog = new GlideModal("edit_worknotes_comments_inc");
dialog.setTitle('Edit Last WorkNotes/Additional Comments');
dialog.setPreference('incid', g_form.getUniqueValue());
dialog.setTitle("Edit Last WorkNotes/Additional Comments");

// Pass the current record's sys_id to the modal
dialog.setPreference("incid", g_form.getUniqueValue());

// Optional: Adjust modal width
dialog.setWidth(550);

// Render the modal
dialog.render();
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
// Business Rule: 'After' Insert on 'sn_hr_core_case'
// Business Rule: After Insert on 'sn_hr_core_case'
(function executeRule(current, previous /*null when async*/) {

if (current.priority == "1" && current.subject_person.getValue('VIP') == 'true') {
var newTask = new GlideRecord('sn_hr_core_task');
newTask.initialize();
newTask.short_description = 'Priority VIP HR task for - ' + current.number;
newTask.assigned_to = current.assigned_to;
newTask.parent = current.sys_id;
newTask.insert();

gs.addInfoMessage('A related HR task has been created for this HR case.');
// Check if priority is high and subject person is a VIP
const isHighPriority = current.priority == '1';
const isVIP = current.subject_person.getValue('VIP') === 'true';

if (isHighPriority && isVIP) {
try {
const task = new GlideRecord('sn_hr_core_task');
task.initialize();

task.short_description = `Priority VIP HR task for - ${current.number}`;
task.assigned_to = current.assigned_to;
task.parent = current.sys_id;

const taskSysId = task.insert();

if (taskSysId) {
gs.addInfoMessage('✅ A related HR task has been successfully created for this VIP HR case.');
} else {
gs.addErrorMessage('⚠️ Failed to create HR task for VIP case.');
}

} catch (err) {
gs.error('Error while creating VIP HR Task: ' + err.message);
}
}

})(current, previous);

Loading