title: How to access the moment object (from moment.js) from a QuickBase custom script
body: <p>I've been writing a custom script for QuickBase, which requires some date manipulation. I decided to use moments.js and, since I'm using it within quickbase, I am loading moments.js dynamically, using $.getscript. I've done this process before with other plugin (jquery.md5.min.js), and this works correctly.</p>
  
  <p>The problem is, even though moment.js is read correctly, when I try to use it (for instance, see the console.log() I added for debugging, I get an error message telling me that "moment is not defined".</p>
  
  <p>I know moment.js is being read because I already had it dumped into the console after loading, and I'm trying to use its functions only after it is loaded via the asynchronous methods. I have also played with a few simple jsfiddles just to make sure I was calling it correctly. I also checked several times the url and it is correct. The rest of my code is also correct (if I comment out the lines with moment(), it works as expected).</p>
  
  <pre><code>$.getScript(domain + dbid_app + urlMoments)
    .done(function(script, textStatus) {
      rightNow = moment();
      dfd.resolve();  // Resolve when the script is finished loading.
      console.log("moments.js has finished loading.\n\n" + textStatus);
      console.log(rightNow);
    })
    .fail(function( jqxhr, settings, exception ) {
      console.log( "Triggered ajaxError handler." );
  });
  </code></pre>
  
  <p>How do I call the moment() function? When running the fiddle, and after looking at many online examples, it is as simple as: <code>var myTime = moment();</code>, but this is not working inside of my script. Is there a chance that, even after loading moments.js with $.getscript(), it was not executed? From what I can see on the source code of moments.js, the factory function should be automatically called, shouldn't it?</p>
  
  <pre><code>(function (global, factory) {
  typeof exports === 'object' &amp;&amp; typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' &amp;&amp; define.amd ? define(factory) :
  global.moment = factory()
  </code></pre>
  
  <p>}</p>
  
  <p>One last thing: the url points to the QuickBase code page I created with moments.js. This is also how I'm using jquery.md5.js without any problems.</p>