Deploying your first NetSuite RESTlet script

If you’d like to try deploying a NetSuite RESTlet script for the first time, then this article is for you. RESTlet scripts prove to be very essential when coming to learn more about NetSuite integrations. They allow developers to write custom codes and lets one get and post data from external applications to NetSuite. Below is a sample code you can copy and paste to start learning. What this code does is to get values from a NetSuite master data upon calling the URL.

/** *@NApiVersion 2.x *@NScriptType Restlet */ define(['N/record'], function(record) { function methodGet(datain) { var recSupplier = record.load({ type: datain.rectype, id: datain.recid }); var RecordInfo = {}; RecordInfo.name = recSupplier.getValue({ fieldId: "entityid" }); RecordInfo.parent = recSupplier.getValue({ fieldId: "companyname" }); RecordInfo.legalname = recSupplier.getValue({ fieldId: "legalname" }); RecordInfo.email = recSupplier.getValue({ fieldId: "email" }); RecordInfo.phone = recSupplier.getValue({ fieldId: "phone" }); return RecordInfo; } return { get: methodGet }; } );

To deploy the RESTlet script, follow these steps:
  1. Copy the code above.
  2. Paste it over the IDE of your choice.
  3. Save it as a .js file.
  4. Log in to NetSuite and upload the JS file by going to Customization > Scripting > Scripts > New.
  5. Give your script a name.
  6. Click on Save.
  7. Click on “Deploy Script”.
  8. Ensure that the deployment page looks like the screenshot below. Upon deployment, you will see the External URL in the page. Click on it to view and test the script functions:ns-restlet-deployment-url
  9. When testing, make sure that parameters “rectype” and “recid” are passed, just as shown in this link:
https://<account-id&gt;.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=74&deploy=1&rectype=vendor&recid=28 LEACC Consulting is a team of NetSuite Certified Developers with IT experience solely dedicated to NetSuite technologies for eight years. We are experts in both SuiteScript 2.0 and SuiteScript 1.0. Our team has worked with 400+ NetSuite scripts and workflows combined. If you need some consulting help of how you can design your NetSuite scripts better, contact us by filling out this form or by commenting below.

Do you have NetSuite Development needs? Do you need help with a solution like this? Click on the link below and let’s have a chat about your project requirements!

Contact us for your NetSuite needs!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s