N/crypto/random Samples

Note:

The content in this help topic pertains to SuiteScript 2.1

The following script samples demonstrate how to use the features of the N/crypto/random module:

Create a RESTlet to roll a dice

The following sample shows how to generate a random integer using the define function:

          /**
 * @NApiVersion 2.1
 * @NScriptType restlet
*/
define(['N/crypto/random'], function(random) {
    return {
     get : function() {
          return JSON.stringify({
            number: random.generateInt({min: 1, max:7})
        })
   }
  }
 }); 

        

General Notices