Skip to content

Instantly share code, notes, and snippets.

View gitmax-it's full-sized avatar

Maxime Dupurgues gitmax-it

View GitHub Profile
@gitmax-it
gitmax-it / 1-single-record query violations.js
Created March 12, 2026 09:35 — forked from thisnameissoclever/1-single-record query violations.js
This script scans all scripts in a given table/field for GlideRecord queries that use `if (gr.next())` WITHOUT a preceding '.setLimit(1)' before '.query()'.
/*
Single-Record GlideRecord Query Violation Detector (with function & line info)
This script scans all scripts in a given table/field for GlideRecord queries that use
`if (gr.next())` WITHOUT a preceding '.setLimit(1)' before '.query()'.
Documentation: https://filthyqueries.snc.guru
Latest version URL: https://filthyqueries-gist.snc.guru
Author: Tim Woodruff (snprotips.com)
Version: 1.05
License: Open Source (MIT License)
Date (US): 7/23/2025
var extServiceRecordSysID = '[PUT_YOUR_SYS_ID]'; // e13982003b98b690c391bf2a85e45a78
var lastApprovalComment = _getLastApprovalComment(extServiceRecordSysID);
if (lastApprovalComment) {
gs.info(lastApprovalComment);
}
function _getLastApprovalComment(_extServiceRecordSysID) {
if (!_extServiceRecordSysID) {
return;
}
@gitmax-it
gitmax-it / SkipApprovals.js
Last active March 11, 2026 15:01
Update inputs
var approvals = ['test'];
var approvalsLength = approvals.length;
function _getManagementControlApprovalsToSkip() {
var approsGR = new GlideRecord('sysapproval_approver');
approsGR.addQuery('sysapproval.sys_class_name', 'u_external_services');
approsGR.addQuery('approval_reason', 'Management Control Team Validation');
approsGR._ge
approsGR.addEncodedQuery('u_active=true^u_source=12d9bd2d3bfba210c391bf2a85e45a79^nameSTARTSWITH1^name!=1ALTES^ORname=NULL^name!=1DRLOG^ORname=NULL^name!=1EDILO^ORname=NULL^name!=1INFOL^ORname=NULL^name!=1MILLE^ORname=NULL^name!=1SCO^ORname=NULL^name!=1SUPLO^ORname=NULL^name!=1VISLO^ORname=NULL^name!=1ZENIT^ORname=NULL');
// sysapproval.sys_class_name=u_external_services^approval_reason=Management Control Team Validation^sysapproval.ref_u_external_services.u_cost_center.nameIN1BI,1BUS,1DDS,1DIROP,1ITEA,1ITFIN,1ITGBS,1ITGF,1ITRUN,1ITSM,1SECU,1STRUC