iosuite

iosuite code manager for NetSuite

View on GitHub

Local Development

  1. Locate and install the iosuite Framework Bundle from the NetSuite bundle library (Bundle #76421)
  2. Clone the iosuite framework from GitHub.com
  3. Install Virtual Box and Vagrant
  4. Register for an ngrok.com account and note the Authentication Key

Vagrant Setup

  1. Open up a command line tool
  2. Change directory into the cloned iosuite directory
  3. Type the command vagrant up
  4. After the process has completed, type vagrant ssh to login to the virtual box
  5. Change directory into "/var/www/iosuite"
  6. Setup the ngrok authentication token by following these instructions
  7. Launch your application by typing forever start iosuite.js
  8. Launch ngrok with a custom domain to start tunneling your localhost, it is recommended that you visit your ngrok url to confirm the server is working
  9. Add the custom domain to the iosuite Users record type in NetSuite, installed from the Bundle, make sure you select your user and don't check "Is Production" or "Is Staging". Be sure to include "https://" to the URL
  10. Visit the sample suitelet to get started

Staging/Production Setup Considerations

  1. The steps for Staging / Production very by desired server setup
  2. io.js must be installed and configured on the server
  3. A valid https certificate is required for NetSuite to properly work
  4. A single entry should be added to the iosuite Users record type that has the server url and "Is Staging" or "Is Production" checked

The iosuite Framework uses a strict coding standard based off of a traditional class based structure. To see an example, check out the sample suitelet provided. This includes a Client Script and a Restlet. Below is a sample of the structure

(function(){

	var private = {};

	public.libraries.global = {{library:global}};

	public.load = function( dataIn ) {
		
		var response = '',
			context = nlapiGetContext(),
			html = {{template:sample}},
			tags = {},
			employeeFilters = [],
			employeeColumns = [],
			employeeRecord;

		/*
		 *  Set Filters and Columns
		 */
		employeeFilters.push( new nlobjSearchFilter('internalid', null, 'is', context.getUser() ) );
		employeeColumns.push( new nlobjSearchColumn('title') );
		try {
			employeeRecord = nlapiSearchRecord('employee', null, employeeFilters, employeeColumns);
		} catch(error) {
			public.libraries.global.handleError( error, 'ERROR' );
		}

		tags.company = context.getCompany();
		tags.environment = context.getEnvironment();
		tags.version = context.getVersion();
		tags.email = context.getEmail();
		tags.username = context.getName();
		tags.jobtitle = employeeRecord[0].getValue('title') || 'Not Set';
		tags.userid = context.getUser();

		response = public.libraries.global.mapTags( html, tags );

		return response;

	};

	return public;

})();
						

The above piece of code is wrapped inside of a self executing function using the (function(){})(); notation. At the beginning there is a local scoped private variable set, where the public variable has been declared and used in the master control file. Then the Suitelet load() method is declared.

It is important to node, there are specific methods that MUST be declared in order for the Suitelet/Restlet to work. For Suitelets it's public.load(), for RESTlets it is public.createCall(), public.readCall(), public.updateCall(), and public.deleteCall();

Other methods are declared but have not been enabled on the live iosuite branch

iosuite comes with several templating systems. The first one allows you to declare libraries, html/css/js calls, among other things. The second is the global library, the global library allows for templating inside of an HTML file. See the sample suitelet for a use case



The MIT License (MIT)

Copyright (c) 2015 SRS Acquiom

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization.