jen
07/14/2022, 5:23 PMname
generated by autonumbering with a prefix (e.g. ABC0001
), how do I get the name of the record in Client SuiteScript?jen
07/14/2022, 5:24 PMjen
07/14/2022, 5:25 PMnlapiGetFieldValue('name');
creece
07/14/2022, 5:30 PMrequire(['N/currentRecord'], function(currentRecord) {
var myRecord = currentRecord.get();
var name = myRecord.getValue({fieldId: 'name'});
console.log('Name: ' + name);
});
jen
07/14/2022, 5:32 PMInclude Name Field
ticked, it’s just a name that gets autogenerated with prefix & minimum number of digits.creece
07/14/2022, 5:33 PMjen
07/14/2022, 5:33 PMjen
07/14/2022, 5:33 PMjen
07/14/2022, 5:33 PMname
jen
07/14/2022, 5:35 PMjen
07/14/2022, 5:35 PMcurrentRecord
for some reasoncreece
07/14/2022, 5:36 PMjen
07/14/2022, 5:37 PMjen
07/14/2022, 5:37 PMcreece
07/14/2022, 5:37 PMcreece
07/14/2022, 5:37 PMjen
07/14/2022, 5:37 PMjen
07/14/2022, 5:38 PMcreece
07/14/2022, 5:38 PMcreece
07/14/2022, 5:38 PMjen
07/14/2022, 5:39 PMjen
07/14/2022, 5:40 PMjen
07/14/2022, 5:40 PMjen
07/14/2022, 5:40 PMvar rec = currentRecord.get();
var name = rec.getValue({fieldId: 'name'}); // null
jen
07/14/2022, 5:41 PMname
to set a value on a different custom record that we use for logging who is editing what recordsjen
07/14/2022, 5:41 PMname
is nullEric B
07/14/2022, 5:45 PMjen
07/14/2022, 5:46 PMcreece
07/14/2022, 5:46 PMjen
07/14/2022, 5:47 PMcreece
07/14/2022, 5:47 PMcreece
07/14/2022, 5:48 PMrequire(['N/currentRecord'], function(currentRecord) {
var myRecord = currentRecord.get();
debugger; // will stop here in the console
var name = myRecord.getValue({fieldId: 'name'});
console.log('Name: ' + name);
});
creece
07/14/2022, 5:48 PMjen
07/14/2022, 5:48 PMjen
07/14/2022, 5:49 PMjen
07/14/2022, 5:49 PMjen
07/14/2022, 5:49 PMcreece
07/14/2022, 5:50 PMjen
07/14/2022, 5:50 PMjen
07/14/2022, 5:50 PMEric B
07/14/2022, 5:50 PMcreece
07/14/2022, 5:50 PMjen
07/14/2022, 5:52 PM// ==UserScript==
// @name NetSuite TamperMonkey Base Script
// @namespace <http://tampermonkey.net/>
// @version 0.2
// @description Handy-dandy things for the browser in NetSuite
// @author <myname>
// @match https://<our_ns_id>.<http://app.netsuite.com/*|app.netsuite.com/*>
// @match https://<our_ns_id>-<http://sb1.app.netsuite.com/*|sb1.app.netsuite.com/*>
// @match https://<our_ns_id>-<http://sb2.app.netsuite.com/*|sb2.app.netsuite.com/*>
// @match https://<our_ns_id>-<http://sb3.app.netsuite.com/*|sb3.app.netsuite.com/*>
// @match https://<our_ns_id>-<http://sb4.app.netsuite.com/*|sb4.app.netsuite.com/*>
// @match https://<our_ns_id>-<http://sb5.app.netsuite.com/*|sb5.app.netsuite.com/*>
// @grant none
// ==/UserScript==
(function() {
console.log('running tampermonkey');
'use strict';
// Resize the popup SuiteScript window because it loads too small to be useful.
if(location.href.indexOf('&target=filesize&') !== -1)
setTimeout(function(){ window.resizeTo(1200, 1000); }, 1000);
// Try to load common modules so that we can use them in the Browser Console.
try {
require(['N/currentRecord', 'N/email', 'N/format', 'N/query', 'N/record', 'N/runtime', 'N/search', 'N/ui/message', 'N/url',
'N/https', 'N/xml', '/SuiteScripts/2.0/module/md_integrity_ss2.1', '/SuiteScripts/2.0/module/md_cas_ss2.1',
'/SuiteScripts/2.0/module/md_moment_ss2.1', '/SuiteScripts/2.0/module/md_records_ss2.1',
'/SuiteScripts/2.0/module/md_entity_ss2.1', '/SuiteScripts/2.0/module/md_formatting_ss2.1',
'/SuiteScripts/2.0/module/md_query_ss2.1', '/SuiteScripts/2.0/module/md_bignumber_ss2.1'],
function(currentRecord, email, format, query, record, runtime, search, message, url, https, xml, md_integrity, md_cas,
moment, md_records, md_entity, md_formatting, md_query, md_bignumber) {
window.currentRecord = currentRecord;
window.email = email;
window.format = format;
window.query = query;
window.record = record;
window.runtime = runtime;
window.search = search;
window.message = message;
window.url = url;
window.https = https;
window.xml = xml;
window.md_integrity = md_integrity;
window.md_cas = md_cas;
window.moment = moment;
window.md_bignumber = md_bignumber;
window.md_formatting = md_formatting;
window.md_records = md_records;
window.query = query;
window.md_entity = md_entity;
window.md_query = md_query;
}
);
} catch (error) {
console.log('Unable to include NetSuite Modules: ' + error);
}
})();
jen
07/14/2022, 5:52 PMjen
07/14/2022, 5:52 PMjen
07/14/2022, 5:53 PMcreece
07/14/2022, 5:53 PMjen
07/14/2022, 5:54 PMjen
07/14/2022, 5:54 PMcreece
07/14/2022, 5:55 PMjen
07/14/2022, 5:55 PMjen
07/14/2022, 5:55 PMjen
07/14/2022, 5:55 PMrequire(['N/currentRecord', 'N/email', 'N/format', 'N/query', 'N/record', 'N/runtime', 'N/search', 'N/ui/message', 'N/url',
'N/https', 'N/xml', '/SuiteScripts/2.0/module/md_integrity_ss2.1', '/SuiteScripts/2.0/module/md_cas_ss2.1',
'/SuiteScripts/2.0/module/md_moment_ss2.1', '/SuiteScripts/2.0/module/md_records_ss2.1',
'/SuiteScripts/2.0/module/md_entity_ss2.1', '/SuiteScripts/2.0/module/md_formatting_ss2.1',
'/SuiteScripts/2.0/module/md_query_ss2.1', '/SuiteScripts/2.0/module/md_bignumber_ss2.1'],
function(currentRecord, email, format, query, record, runtime, search, message, url, https, xml, md_integrity, md_cas,
moment, md_records, md_entity, md_formatting, md_query, md_bignumber) {
window.currentRecord = currentRecord;
window.email = email;
window.format = format;
window.query = query;
window.record = record;
window.runtime = runtime;
window.search = search;
window.message = message;
window.url = url;
window.https = https;
window.xml = xml;
window.md_integrity = md_integrity;
window.md_cas = md_cas;
window.moment = moment;
window.md_bignumber = md_bignumber;
window.md_formatting = md_formatting;
window.md_records = md_records;
window.query = query;
window.md_entity = md_entity;
window.md_query = md_query;
}
);
creece
07/14/2022, 5:55 PMjen
07/14/2022, 5:56 PMjen
07/14/2022, 5:56 PMjen
07/14/2022, 5:56 PMcreece
07/14/2022, 5:56 PMjen
07/14/2022, 5:57 PMcreece
07/14/2022, 5:58 PMjen
07/14/2022, 5:59 PMdbarnett
07/14/2022, 7:09 PMrequire(['N'], function (N) {
Object.assign(window, N);
});
dbarnett
07/14/2022, 7:30 PMfunction requireCustomModules() {
var filesData = getProjectFiles();
var deps = filesData.map((x) => x.fullPath);
require(deps, function (...args) {
args.forEach((e, i) => {
var moduleName = filesData[i].name.replace('.min', '');
window[moduleName] = args[i];
});
});
}
although you could replace getProjectFiles
to just hardcode array of the paths to stuff you want, just to reduce a bit more clutter in your example when additional custom modules get progressively added