Skip to content
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions Client-Side Components/UI Pages/BulkUpdate Worknotes/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

Bulk Update Worknotes

Script Type: UI Action, Table: incident, List banner button: True, Client: True, Show update: True, OnClick: functionName()

Script Type: UI Page Category: General

Goal: To update the worknotes for multiple tickets in a single view

Walk through of code: So in the incident List view we do have a list banner button called "Bulk Updates" so that was the UI Action configured with the script which has used the GlideModel API to call the UI page which is responsible to get the multiple tickets and worknotes value and then update to the respective ticket and store in the worknotes in journal entry. For this the HTML part in the UI page is configured with two fields, one for the multiple list of tickets, and then the worknotes field, and one submit button to save that into the table.
And the Processing Script is used to get each ticket number and then check the valid tickets and query the respective table, and then update the worknotes of each respective ticket if it is valid. Otherwise, it won't update.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Table: incident, List banner button: True, Client: True, Show update: True, OnClick: bulkupdate()

function bulkupdate() {
var modalT = new GlideModal("BulkUpdate", false, 1200);
modalT.setTitle("Bulk Update Worknotes");
modalT.render();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function bulkupdate() {
document.getElementById("spinner-btn").style.display = "block";
document.getElementById("submit-btn").style.display = "none";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j2:set var="jvar_hide_response_time" value="true" />
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap5.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" />

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>

<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.7/js/dataTables.bootstrap5.min.js"></script>
</head>

<body>
<!-- Alert Message -->
<div id="primary-message" style="display:none;" class="alert alert-primary" role="alert">

</div>
<div id="error-message" style="display:none;" class="alert alert-danger" role="alert">
Error - An error has occurred when trying to update Work Notes.
</div>
<div id="warning-message-invalid-entry" style="display:none;" class="alert alert-warning" role="alert">
Warning - Invalid list of Incident Tickets or Work Note field. Please try again.
</div>
<div id="warning-message-invalid-tickets-valid-entry" style="display:none;" class="alert alert-warning" role="alert">

</div>

<!-- Bulk Update Work Notes Form -->
<div id="form-div" class="container mt-3">

<g:ui_form>
<div class="mb-3 mt-3">
<label class="text-lg" for="ticket_list">Incident Ticket List</label>
<input type="text" class="form-control text-sm" id="ticket_list" placeholder="Enter list of Incident Tickets, separated by commas. (Example: INC001001, INC001002, ...)" name="ticket_list" required="true" />
</div>
<div class="mb-3">
<label class="text-lg" for="work_note_to_apply">Work Note to Apply</label>
<textarea type="text" class="form-control text-sm" id="work_note_to_apply" placeholder="Enter work note to apply here." name="work_note_to_apply" required="true" rows="6" />
</div>
<div class="d-grid gap-2 col-6 mx-auto">
<button id="submit-btn" class="btn btn-primary btn-lg text-lg" onclick="bulkupdate()">Submit</button>
<button id="spinner-btn" style="display:none" class="btn btn-primary btn-lg text-lg" type="button" disabled="true">
<span class="spinner-border spinner-border-lg me-2" role="status" aria-hidden="true"></span>
Loading...
</button>
</div>
</g:ui_form>


</div>
</body>
<style>
textarea {
resize: none;
}

.text-lg {
//font-size: 1.125rem;
font-size: large;
line-height: 1.75rem;
}

.text-md {
//font-size: 1rem;
font-size: medium;
line-height: 1.5rem;
}

.text-sm {
//font-size: .75rem;
font-size: small;
line-height: 1rem;
}

.text-xs {
//font-size: .75rem;
font-size: smaller;
line-height: 1rem;
}
</style>

</html>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// gs.info("Ticket List :"+ticket_list);

// Sepetation of ticket based on the comma.
var ticketlist = ticket_list;
var formatted_ticket_list = ticketlist.split(/[ ,]+/).filter(Boolean);
var valid_ticket_list = [];
var invalid_ticket_list = [];


// Checks the first ten Incident ticket into an array which start with INC
for (var i = 0; i < formatted_ticket_list.length; i++) {
if (formatted_ticket_list[i].startsWith('INC')) {
if (formatted_ticket_list[i].length == 10)
valid_ticket_list.push(formatted_ticket_list[i]);
else {
invalid_ticket_list.push(formatted_ticket_list[i]);
}
} else {
invalid_ticket_list.push(formatted_ticket_list[i]);
}
}

// Looping into each ticket to update the worknotes based on the table
for (var k = 0; k < valid_ticket_list.length; k++) {
var gr_inc = new GlideRecordSecure('incident');
gr_inc.addQuery('number', valid_ticket_list[k]);
gr_inc.query();

if (gr_inc._next()) {
gr_inc['work_notes'] = work_note_to_apply;
gr_inc.update();
} else {
//If the ticket number was not found, add to Invalid Ticket List
invalid_ticket_list.push(valid_ticket_list[k]);
}
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading