I want to quickly test some code that will use mom...
# suitescript
c
I want to quickly test some code that will use momentjs but I don't want to go to the effort of deploying a script. I can write my POC code in the debugger and test from there but I'd need a way to access the momentjs file/library from the debugger - is that possible?
b
if its just the normal moment without timezones, then you can just require it via its filepath
c
Is there a different between norma and the one with timezones?
Im looking at a single 18000 line file called momentjs which someone else has uplaoded
I could require the file sat in a CDN.
its an addon to timezone
which is defined like
Copy code
define(['moment'], factory);
c
It's not that one then
b
if its the normal one, just put the file in the suitescript folder and require its via its file path
c
require('SuiteScripts/momentjs/moment.js')
Like so?
b
use an absolute path
c
I don't know the absolute path
b
c
I missed the / at the start of the string
require didn't work
define did though
b
whats not working
c
Hard to tell - debugger just exits on the require line
so I'm trying to write it as define
require('/SuiteScripts/momentjs/momentjs.js'); const NSDate = '5/26/2022';
never hits line 2
b
thats not how you want to use it in the debugger
c
I think I need to do some reading before this becomes a quicker way of me doing POCs
t
@Craig should be like this in debugger
Copy code
require(['/SuiteScripts/moment.js'],function(moment){

    const date = moment().add(5,'d')
    const x = 0;
 });
c
Yeah thanks, I put the code into a callback and got it working
s
if you don’t wanna do callback all the time, try the following:
Copy code
require(['/SuiteScripts/momentjs/momentjs.js']);
const moment = require('/SuiteScripts/momentjs/momentjs.js');
const date = moment().add(5, 'd');
👍 1
just updated, pressed enter early 🙂
make sure to run the 1st line in advance before continuing with the rest of the code