Using `runtime.getCurrentScript()` is there anyway...
# suitescript
d
Using
runtime.getCurrentScript()
is there anyway to get the numeric id of the script as opposed to the string
customscript_xxx
? I'm not seeing it on the
runtime.Script
object at all.
n
have you tried:
Copy code
var scriptObj = runtime.getCurrentScript();
log.debug("Script Id: " + scriptObj.id);
Not sure if that's what you need or what yo're seeing
d
yeah, logging that guy is returning the
customscript_xxx
n
bah. Maybe JSON.stringify in case it's not in the help?
d
I'm trying to get the ID so I can set it somewhere else. Basically building a logging utility, and I want to set a custom field on a custom record with the script an error came from. But
.setValue
doesn't work with
customscript_xxx
, so I need that numeric id.
n
Why not make your custom field a text field?
d
yeah, I could do that, it'd just make for faster debugging to click through a link of the script to get to the execution logs.
(Not to mention my script ids are not as readable as the names themselves)
but yeah,
toJSON
and
toString
are both not showing any additional information. Might just have to go with script strings
n
If you know the script id / deployment id you can resolve the url and use taht as a hyperlink intstead to click through
d
ohhhh nifty thought! thanks!
👍 1
n
Copy code
var output = url.resolveScript({
    scriptId: 'custom_script',
    deploymentId: 'custom_script_deployment',
    returnExternalUrl: true
});
a
@dmashburn3 You can also do a search with the ID you are getting to get the internal id.
d
yeah, being a utility that is going to be used a fair bit throughout the code base, I don't want it running a search every time it gets called
thanks though!
a
@dmashburn3 You mentioned you are trying to build a logging utility, there some specific limitation you have with the regular script logs?
Maybe you are better just searching the script logs and gather all the logs you need and storing them in the custom record you want.
d
It's for our SuiteApp that we put in accounts and we are building a tool that logs more than just script errors. It also puts the data into a format more accessible for our implementation team to use.
j
do a search once and then cache or memoize the customscript_x => 123 mapping