- Ensure that you are in the scope you intend to put this script in. If you're uncertain, I recommend selecting the Global application scope.
- Create a new Script Include in the
sys_script_includetable. - Set the Name field to
DistanceCalculator. - Set Accessible from to "All application scopes".
- Set the description field to a meaningful description of the function of the Script Include (such as from the comments above 1the main public function in the script).
- Copy the script from the
DistanceCalculator.jsfile in this Gist (below), and paste it into the Script field. - Submit the record.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //This is a modification of the original parametric model's scad code from this model: | |
| //The only modification to the original code is on line 21 (line 10 of the original), which previously used to read: `cylinder(d=14.4,h=12+walls, $fn=8);` | |
| //This line has been updated to: `cylinder(d=14.4,h=12+walls, $fn=8);` | |
| // | |
| //Thanks to user `@josh.medley` for this fix. I did not figure this out, I just modified the code as per his instructions and posted the gist. | |
| // | |
| //Original model: | |
| // https://makerworld.com/en/models/396738-multiboard-cylinder#profileId-885003 | |
| //Parametric model maker: | |
| // https://makerworld.com/en/makerlab/parametricModelMaker?designId=396738&from=model_page&modelName=Multiboard-cylinder.scad&scadUrl=https%3A%2F%2Fmakerworld.bblmw.com%2Fmakerworld%2Fmodel%2FDSM00000000396738%2Fmsfile%2F2024-03-27_50hbfri8viwz.scad%3Fat%3D1785940312%26exp%3D1785940612%26key%3Dfa1bbc520a43474a17d26f096774b715%26uid%3D1096379941&unikey=cba631a4-9f62-441e-9fe5-42edb0316122 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {String} originLocationID - The sys_id of the Location record for the origin point. | |
| * This should be the sys_id of a valid record in the cmn_location table. | |
| * | |
| * @param destinationLocationID - The sys_id of the Location record for the destination point. | |
| * This should be the sys_id of a valid record in the cmn_location table. | |
| * | |
| * @param {('km'|'miles'|'mile'|'mi'|'yards'|'yd'|'inches'|'in'|'feet'|'ft'|'meters'|'m'|'centimeters'|'cm'|'millimeters'|'mm'|'nautical miles'|'nm')} [distanceUnits='km'] | |
| * - The units of the distance. Default is 'km'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Local (instance-specific) System Property Script Include | |
| * More info available at https://localprop.snc.guru | |
| * | |
| * A ServiceNow JavaScript ES5 class, LocalProperty, for getting and setting instance-specific | |
| * system properties. | |
| * See method documentation for more information. | |
| * @param {string} [instanceNameOverride=] - Override the name of the instance that's currently | |
| * executing this code. | |
| * For example, if you have a system property such as "my_prod_instance.some_property" which |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onChange(control, oldValue, newValue, isLoading, isTemplate) { | |
| if (isLoading) { | |
| return; | |
| } | |
| var scriptHasUncommentedLines, flyoutText; | |
| var isAdvanced = (newValue === 'true'); | |
| var origScriptVal = (g_form.getValue('script').trim()); | |
| var doesScriptExist = (!!origScriptVal); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Client-side example usage | |
| doThing(); | |
| function doThing() { | |
| new EfficientGlideRecord('incident') | |
| .setLimit(10) | |
| .addNotNullQuery('assignment_group') | |
| .addField('number') | |
| .addField('short_description') | |
| .addField('assignment_group', true) //Get display value as well |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| showSimpleLoadingMessage('Retrieving data'); | |
| var arrListElements = slowFunctionThatReturnsAnArrayOfStrings() || ['Element 1', 'Element 2', 'Element 3']; | |
| var flyoutListHTML = getHTMLListFromArray( | |
| arrListElements, | |
| 'disc', | |
| 'Element: ' | |
| ); | |
| g_form.clearMessages(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gaSlowGlideAjaxCall = new GlideAjax('{some_glideajax_script_include'); | |
| //todo: Set the second argument to the method you want to execute from your GlideAjax Script Include | |
| gaSlowGlideAjaxCall.addParam('sysparm_name', '{some_slow_glideajax_script_method'); | |
| //todo: Add whatever other GlideAjax parameters you need to add below, such as: | |
| gaSlowGlideAjaxCall.addParam('record_sys_id', g_form.getUniqueValue()); | |
| gaSlowGlideAjaxCall.addParam('some_field_value', g_form.getValue('{field_name}')); | |
| //Show animated form message: "Processing request..." | |
| //This will continue to show and animate until we call stopAnimatedLoadingFieldMessage(), | |
| // which we'll do in the callback function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gaSlowGlideAjaxCall = new GlideAjax('{some_glideajax_script_include'); | |
| //todo: Set the second argument to the method you want to execute from your GlideAjax Script Include | |
| gaSlowGlideAjaxCall.addParam('sysparm_name', '{some_slow_glideajax_script_method'); | |
| //todo: Add whatever other GlideAjax parameters you need to add below, such as: | |
| gaSlowGlideAjaxCall.addParam('record_sys_id', g_form.getUniqueValue()); | |
| //Show animated form message: "Processing request..." | |
| //This will continue to show and animate until we call g_form.clearMessages(), | |
| // which we'll do in the callback function | |
| //todo: Update message from "Processing request" to whatever is appropriate to your situation. |
NewerOlder