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
7 changes: 7 additions & 0 deletions Background Scripts/CreateIncident.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'New Incident';
gr.description = 'This is a new incident created by a background script.';
gr.insert();
gs.log('New incident created with sys_id: ' + gr.sys_id);
8 changes: 8 additions & 0 deletions Background Scripts/Delete Closed Incident/DeleteIncident.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var gr = new GlideRecord('incident');
gr.addQuery('state', '7');
gr.query();
var count = 0;
while (gr.next()) {
gr.deleteRecord();
count++;
}
1 change: 1 addition & 0 deletions Background Scripts/Delete Closed Incident/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Delete All those incident which are closed so this snippet is basically for that
9 changes: 9 additions & 0 deletions Background Scripts/Get Current Month/CurrentMonth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var currentDate = new GlideDate();
var monthNumber = currentDate.getMonth();
var monthNames = [
"Jan", "Feb", "Mar", "Apr", "May", "June",
"July", "Aug", "Sept", "OCT", "Nov", "Dec"
];

var monthName = monthNames[monthNumber - 1];
gs.log(monthName);
1 change: 1 addition & 0 deletions Background Scripts/Get Current Month/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Code Snippets is just to get the current month name
8 changes: 8 additions & 0 deletions Background Scripts/GetAllActiveIncident
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var op = new GlideRecord('incident');
op.addActiveQuery();
op.query();
while(op.next())
{
gs.log('Incident Number :'+op.number);
gs.log('Incident Description : '+op.short_description);
}
7 changes: 7 additions & 0 deletions Background Scripts/Update Incident/UpdateIncident.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var gr = new GlideRecord('incident');
gr.addQuery('state', '1');
gr.query();
while (gr.next()) {
gr.priority = '2';
gr.update();
}
15 changes: 15 additions & 0 deletions Background Scripts/UpdatePriorityBasedOnImpact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.addQuery('impact', '2');
gr.query();
while (gr.next()) {

if (gr.impact == '2') {
gr.priority = '1';
} else {
gr.priority = '2';
}
gr.update();
}

15 changes: 15 additions & 0 deletions Client Scripts/FlashEmptyField
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function onLoad() {
// Get the field element
var field = g_form.getControl('short_description');

// Check if the field is empty
if (g_form.getValue('short_description').trim() === '') {
// Apply CSS style to flash the field
field.style.backgroundColor = 'red';

// Set a timeout to reset the background color after a few seconds
setTimeout(function() {
field.style.backgroundColor = '';
}, 2000); // Change '2000' to set the duration in milliseconds
}
}
13 changes: 13 additions & 0 deletions Client Scripts/PreventFutureDateSelection
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var selectedDate = new GlideDate(newValue);
var currentDate = new GlideDate();

if (selectedDate > currentDate) {
g_form.clearValue('your_date_field'); // Replace 'your_date_field' with the actual field name
alert('Future dates are not allowed.');
}
}
16 changes: 16 additions & 0 deletions GlideRecord/CheckNewRecord
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var gr = new GlideRecord('incident');


if (gr.isNewRecord()) {
gs.log("This is a new incident record.");
} else {
gs.log("This is an existing incident record.");
}
gr.addQuery('active', true);
gr.query();

while (gr.next()) {

gs.log('Incident Number: ' + gr.number);
gs.log('Short Description: ' + gr.short_description);
}
11 changes: 11 additions & 0 deletions UI Actions/OpenGooglePage
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(function executeUIAction(current, parent) {
var url = "https://www.google.com";
var openInNewTab = true;

if (openInNewTab) {
var win = window.open(url, "_blank");
win.focus();
} else {
window.location.href = url;
}
})(current, current);
9 changes: 9 additions & 0 deletions Updating Incident
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var incidentGR = new GlideRecord('incident');

// Replace 'INC0010001' with the actual incident number or use a query to find it
if (incidentGR.get('number', 'INC0010001')) {
incidentGR.short_description = 'Updated short description for Priority 1 incident';
incidentGR.update();
} else {
gs.info('Incident not found');
}
Loading