I'm working on using a custom module inside of my development NetSuite account.
In this example, I have a file called SS2_CustomModuleTest.js. It looks like this:
define([], function() { function ConvertNSFieldToFloat(value, blankIfNull) { if (blankIfNull) { if (value == null || value == '') return ''; else return parseFloat(value); } else { if (value == null || value == '') return 0; else return parseFloat(value); } } function ConvertLbToKG(lb) { return ConvertNSFieldToFloat(lb) * 0.453592; } function ConvertPSIToKPA(psi) { return psi * 6.8948; } return { ConvertLbToKG : ConvertLbToKG, ConvertPSIToKPA : ConvertPSIToKPA, ConvertNSFieldToFloat : ConvertNSFieldToFloat }; }); Then I have Suitelet script that looks like this: /** * @NApiVersion 2.x * @NScriptType Suitelet * @NModuleScope SameAccount */ define(['N/ui/serverWidget', '/.bundle/125086/SS2_CustomModuleTest'], /** * @param {serverWidget} serverWidget */ function(serverWidget, SS2_CustomModuleTest) { var obj = {}; obj.onRequest = function(context) { if (context.request.method === 'GET') { var form = serverWidget.createForm({ title: 'Custom Module Test' }); var modTest = SS2_CustomModuleTest.ConvertLbToKG(1000); var field = form.addField({ id: 'custpage_test', label: 'Cust Module Test', type: serverWidget.FieldType.TEXT }); field.defaultValue = modTest; context.response.writePage(form); } else { // post } }; return obj; }); I created a bundle in the Development NetSuite account with a bundle ID of 125086. What I'm trying to do is define the module in my Suitelet and have it work when I copy the bundle to the Production NetSuite account and when I install it into Deployment NetSuite accounts.I'm attempting to use a virtual file path, per NetSuite's documentation but it doesn't appear to work in the Development account. I get the following error:{"type":"error.SuiteScriptModuleLoaderError","name ":"INVALID_BUNDLE_VIRTUAL_PATH__1","message":"Inva lid bundle virtual path : /.bundle/125086/SS2_CustomModuleTest.js","stack":[]}I'm currently testing to make sure it works in the production and deployment accounts.What is the best practice to do this? What is the best way to define custom modules and have them work when bundles are copied and installed in other NetSuite accounts? I cannot change the define(['N/ui/serverWidget', '/.bundle/125086/SS2_CustomModuleTest']
code because it will part of my bundle.Thanks!Nathan