NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Edit script // @namespace http://tampermonkey.net/ // @version 0.1 // @description Edit script file in CodeMirror (from script record or deployment record). Works in pair with my NetSuite CodeMirror editor script // @author vlada79 // @include *://*.app.netsuite.com/app/common/scripting/script.nl // @grant none // @run-at context-menu // @license MIT // @copyright 2019, vlada79 (https://openuserjs.org/users/vlada79) // ==/UserScript== (function() { 'use strict'; var fileId = null; // If on script deployment record var scriptId = nlapiGetFieldValue('script'); if (scriptId) { var scriptSearch = nlapiCreateSearch('script', ['internalid', 'is', nlapiGetFieldValue('script')], [new nlobjSearchColumn('scriptfile')]).runSearch().getResults(0, 3); if (scriptSearch.length == 1) { fileId = scriptSearch[0].getValue('scriptfile'); } } // If on Script record // Get ID in edit mode fileId = fileId || nlapiGetFieldValue('scriptfile'); if (!fileId) { // Get ID in view mode var fileHref = jQuery('a.smalltext[href!="#"]').attr('href'); if (!fileHref) return; fileId = fileHref.match('id=([0-9]*)')[1]; } var url = '/app/common/record/edittextmediaitem.nl?e=T&id=' + fileId; window.open(url, '_blank'); })();