Skip to content

Instantly share code, notes, and snippets.

@afaulkinberry
afaulkinberry / CSDashboard.html
Last active December 8, 2022 11:59
ServiceNow UI Page using AngularJS
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:requires name="angular-min.1.3.16.jsdbx" />
<link href="3ca86ab937380a006215d68543990ef6.cssdbx" rel="stylesheet" type="text/css"></link>
<g2:evaluate var="jvar_stamp">
var gr = new GlideRecord('sys_ui_script');
gr.get("13a5ea4d37300a006215d68543990e41");
gr.getValue('sys_updated_on');
</g2:evaluate>
<g:requires name="cs-dashboard-script.jsdbx" params="cache=$[jvar_stamp]" />
@afaulkinberry
afaulkinberry / HTTPConn.js
Last active August 29, 2015 14:26
AngularJS - http connection to Yahoo weather
function fetchWeather(zip) {
openweather.getWeather(zip).then(
function(data){
$scope.weatherData = data.data.query.results.channel;
$scope.weatherDays = $scope.weatherData.item.forecast;
var desc = $scope.weatherData.item.description.split("\"/><br", 2);
$scope.weatherPic = desc[0].replace("\n<img src=\"", "");
},
function(data){ return; }
);
@afaulkinberry
afaulkinberry / objSort.js
Last active August 29, 2015 14:26
Sort Javascript Objects by Property
//property = first_name
function compare(a,b) {
if (a.first_name < b.first_name)
return -1;
if (a.first_name > b.first_name)
return 1;
return 0;
}
//object array = data.records
var sorted = data.records.sort(compare);
@afaulkinberry
afaulkinberry / angSortArr.js
Last active August 29, 2015 14:26
AngularJS - New array from object array based on property value
$scope.sortedArr = function(prop, propVal, masterArr){
var newArr = [];
angular.forEach(masterArr, function(value, key) {
if(angular.equals(value[prop], propVal)){ newArr.push(value); }
});
return newArr;
};
var objArr = [
{ "first_name" : "George", "last_name" : "Washington" },
@afaulkinberry
afaulkinberry / noDuplicates.js
Last active March 5, 2019 21:41
AngularJS - Remove duplicate objects from object array
function(arr){
var newArr = [];
angular.forEach(arr, function(value, key) {
var exists = false;
angular.forEach(newArr, function(val2, key) {
if(angular.equals(value.id, val2.id)){ exists = true };
});
if(exists == false && value.id != "") { newArr.push(value); }
});
return newArr;
@afaulkinberry
afaulkinberry / newGDForm.js
Last active August 29, 2015 14:26
ServiceNow - GlideDialogs
//Opens dialog window container - Table Form View
function newGDF(tableName, sysID, disVal){
var dialog = new GlideDialogForm('View User', tableName);
dialog.setTitle(disVal);
dialog.setSysID(sysID);
dialog.addParm('sysparm_view', 'sys_popup');
dialog.addParm('sysparm_form_only', 'true');
dialog.render();
}
@afaulkinberry
afaulkinberry / GlideAjax.js
Last active August 29, 2015 14:26
ServiceNow - Glide System
function onSubmit() {
var alrtMsg = null;
var kWords = g_form.getValue('short_description');
var ga = new GlideAjax('CheckKnownIssues'); //Use the name of the Script Include
ga.addParam('sysparm_name', 'findKeywords'); //findKeywords is a function in the include
ga.addParam('sysparm_keyWrds', kWords ); //kWords is a variable in the include (var kywrds = this.getParameter('sysparm_keyWrds');)
ga.getXMLWait(); //Wait on the script to complete
alrtMsg = ga.getAnswer(); //Get the returned value from the Script Include
if (alrtMsg != null) {
return confirm(alrtMsg + "\n\n" + "Please click \"OK\" if you would still like to submit this reqest.");
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H1
Set XConn = New ADODB.Connection
Set XRecSet = New ADODB.Recordset
XConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=U:\User Admin Tools\User Tables.xlsm;" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
public static void buildCN()
{
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + filePath;
try { cn.Open(null, null, null, 0); }
catch (Exception e) { Console.WriteLine(e.ToString()); }
}
public static void closeCN(){
try{ cn.Close(); }
catch (Exception e) { Console.WriteLine(e.ToString()); }
}