Last active
January 26, 2026 21:10
-
-
Save ChecksumFailed/f75fd74bfcfadf573364cdcd209a875a to your computer and use it in GitHub Desktop.
Borrowed from sn utils. Create hyperlinks for any glide lists on your current page.
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 () { | |
| 'use strict'; | |
| // Check for SN Utils extension immediately (before anything else) | |
| if (typeof snusettings !== 'undefined' || | |
| document.querySelector('.snutn, #snuInstanceTag')) { | |
| return; // Exit if SN Utils is active to avoid conflicts | |
| } | |
| var processedElements = new Set(); | |
| function cfProcessGlideLists() { | |
| document.querySelectorAll('div[type=glide_list]').forEach(function (elm) { | |
| try { | |
| // Skip if already processed | |
| if (processedElements.has(elm.id)) return; | |
| // Extract field name from element ID (e.g., "label.incident.watch_list" -> "watch_list") | |
| var field = elm.id.split('.')[2]; | |
| if (!field) return; | |
| // Get field metadata | |
| var glideUIElement = g_form.getGlideUIElement(field); | |
| if (!glideUIElement) return; | |
| // Check if field has a reference table | |
| var table = glideUIElement.reference; | |
| if (!table || table === 'null') return; | |
| // Find the display paragraph element | |
| var displayPara = elm.nextSibling ? elm.nextSibling.querySelector('p') : null; | |
| if (!displayPara) return; | |
| // Get the select element with options | |
| var selectElement = document.querySelector('select[id$="' + field + '"]'); | |
| if (!selectElement) return; | |
| // Extract display labels from options | |
| var labels = Array.from(selectElement.querySelectorAll('option')).map(function (opt) { | |
| return opt.innerText; | |
| }); | |
| // Get sys_ids from hidden input | |
| var hiddenInput = elm.nextSibling.querySelector('input[type=hidden]'); | |
| if (!hiddenInput) return; | |
| var values = hiddenInput.value.split(','); | |
| // Ensure labels and values match | |
| if (labels.length !== values.length) return; | |
| // Build hyperlinks | |
| var links = []; | |
| var sysIDRegex = /[0-9a-f]{32}/i; | |
| for (var i = 0; i < labels.length; i++) { | |
| if (values[i] !== "" && sysIDRegex.test(values[i])) { | |
| links.push( | |
| '<a href="/' + table + '.do?sys_id=' + values[i] + '" ' + | |
| 'target="_blank" ' + | |
| 'style="color: #0066cc; text-decoration: none; margin-right: 8px;">' + | |
| '<span class="icon icon-info" style="font-size: 10px; margin-right: 2px;" ' + | |
| 'title="Click to open ' + labels[i] + ' record"></span>' + | |
| labels[i] + | |
| '</a>' | |
| ); | |
| } else if (values[i] !== "") { | |
| links.push('<span style="margin-right: 8px;">' + labels[i] + '</span>'); | |
| } | |
| } | |
| // Update the display paragraph with hyperlinks | |
| displayPara.innerHTML = links.join(''); | |
| displayPara.style.display = 'inline'; | |
| // Mark as processed | |
| processedElements.add(elm.id); | |
| } catch (e) { | |
| // Silently fail for individual fields to not break others | |
| } | |
| }); | |
| } | |
| addLateLoadEvent(function () { | |
| // Process immediately when form loads | |
| cfProcessGlideLists(); | |
| // Check again for late-loading related lists | |
| setTimeout(cfProcessGlideLists, 1000); | |
| setTimeout(cfProcessGlideLists, 2000); | |
| }); | |
| })(); |
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 () { | |
| 'use strict'; | |
| // Check for SN Utils extension immediately (before anything else) | |
| if (typeof snusettings !== 'undefined' || | |
| document.querySelector('.snutn, #snuInstanceTag')) { | |
| return; // Exit if SN Utils is active to avoid conflicts | |
| } | |
| var processedElements = new Set(); | |
| function cfProcessGlideLists() { | |
| document.querySelectorAll('div[type=glide_list]').forEach(function (elm) { | |
| try { | |
| // Skip if already processed | |
| if (processedElements.has(elm.id)) return; | |
| // Extract field name from element ID (e.g., "label.incident.watch_list" -> "watch_list") | |
| var field = elm.id.split('.')[2]; | |
| if (!field) return; | |
| // Get field metadata | |
| var glideUIElement = g_form.getGlideUIElement(field); | |
| if (!glideUIElement) return; | |
| // Check if field has a reference table | |
| var table = glideUIElement.reference; | |
| if (!table || table === 'null') return; | |
| // Find the display paragraph element | |
| var displayPara = elm.nextSibling ? elm.nextSibling.querySelector('p') : null; | |
| if (!displayPara) return; | |
| // Get the select element with options | |
| var selectElement = document.querySelector('select[id$="' + field + '"]'); | |
| if (!selectElement) return; | |
| // Extract display labels from options | |
| var labels = Array.from(selectElement.querySelectorAll('option')).map(function (opt) { | |
| return opt.innerText; | |
| }); | |
| // Get sys_ids from hidden input | |
| var hiddenInput = elm.nextSibling.querySelector('input[type=hidden]'); | |
| if (!hiddenInput) return; | |
| var values = hiddenInput.value.split(','); | |
| // Ensure labels and values match | |
| if (labels.length !== values.length) return; | |
| // Build hyperlinks | |
| var links = []; | |
| var sysIDRegex = /[0-9a-f]{32}/i; | |
| for (var i = 0; i < labels.length; i++) { | |
| if (values[i] !== "" && sysIDRegex.test(values[i])) { | |
| links.push( | |
| '<a href="/' + table + '.do?sys_id=' + values[i] + '" ' + | |
| 'target="_blank" ' + | |
| 'style="color: #0066cc; text-decoration: none; margin-right: 8px;">' + | |
| '<span class="icon icon-info" style="font-size: 10px; margin-right: 2px;" ' + | |
| 'title="Click to open ' + labels[i] + ' record"></span>' + | |
| labels[i] + | |
| '</a>' | |
| ); | |
| } else if (values[i] !== "") { | |
| links.push('<span style="margin-right: 8px;">' + labels[i] + '</span>'); | |
| } | |
| } | |
| // Update the display paragraph with hyperlinks | |
| displayPara.innerHTML = links.join(''); | |
| displayPara.style.display = 'inline'; | |
| // Mark as processed | |
| processedElements.add(elm.id); | |
| } catch (e) { | |
| // Silently fail for individual fields to not break others | |
| } | |
| }); | |
| } | |
| addLateLoadEvent(function () { | |
| // Process immediately when form loads | |
| cfProcessGlideLists(); | |
| // Check again for late-loading related lists | |
| setTimeout(cfProcessGlideLists, 1000); | |
| setTimeout(cfProcessGlideLists, 2000); | |
| }); | |
| })(); |
Author
ChecksumFailed
commented
Jan 26, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment