```All SuiteScript API Modules are unavailable whi...
# suitescript
m
Copy code
All SuiteScript API Modules are unavailable while executing your define callback.
Has anyone encountered this error?
s
Yes, do not put calls to netsuite APIs outside of the entry points
m
what does it mean?
s
It means what I just said, do not pull calls to the netsuite APIs outside of the entry points to the script.
😂 1
d
show the script
m
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType Restlet
 */

define([
  'N/search',
  'N/error'
], (search, error) => {
	  const mappingRecordType = {
    subsidiaryPayFrom: { recordType: search.Type.SUBSIDIARY, field: 'externalid' }
      }
  function doPost(requestBody) {
    return 'ok'
  }
  return {
    post: doPost
  }
})
search create this error
s
you are using search.Type outside of the entry point, stop doing that
m
aaa
Copy code
function doPost(requestBody) {
    return 'ok'
  }
Copy code
function doPost(requestBody) {
const mappingRecordType = {
    subsidiaryPayFrom: { recordType: search.Type.SUBSIDIARY, field: 'externalid' }
      }
    return 'ok'
  }
s
If you need to define global variables that reference netsuite APIs/values, you need to initialize them inside the entry point... or just put the variable in the entry point as you did there
m
entry point - this means (post, get, ...)
👍 1
thank you