SuiteScript hooks are functions executed during a flow within NetSuite using scripts (RESTlets, Scheduled or MapReduce (depending upon the hook type and NetSuite version). Hooks should be configured in a JavaScript file in the NetSuite File Cabinet as a global function. A single file can support multiple functions for multiple hooks. When the flow runs, the Celigo platform loads and executes the hooks. NetSuite has SuiteScript available in two versions, SuiteScript 1.0 and SuiteScript 2.0, both of which are supported in the Celigo platform.
You can leverage full SuiteScript capabilities in both exports and imports to customize data. Some simple examples of what you can do with a SuiteScript hook include performing a search in NetSuite or loading a record via the SuiteScript APIs within NetSuite to add additional data or make a decision before exporting or importing a record. Using NetSuite hooks during a flow saves external API calls needed from outside of NetSuite to achieve the same functionality, thereby optimizing the flow's performance.
In a NetSuite export, you can use the pre send hook, which is invoked after the data is collected but before it’s sent to the Celigo platform. In a NetSuite import, the data is sent from the Celigo platform to NetSuite to create or update records. The data goes through several stages, during which you can use the pre map, post map, and post submit hooks to configure your data.
Learn more about SuiteScript 2.0 and the integrator.io SuiteApp.
-
Click the Hooks icon in Flow builder on your export or import.
-
In the SuiteScript hooks section, provide the Function and the File internal id for the SuiteScript hook you are linking to.
Before you add a SuiteScript hook to an export or import you must find the File internal ID.
Note
The File internal id (or file path) is the ID of the script file stored in the NetSuite File Cabinet. It must be accessible using the role you used to configure your NetSuite connection.
-
Navigate to NetSuite → Documents → Files → File Cabinet.
-
Find the correct folder or file.
-
The file’s internal ID is located next to the filename. A file path can be constructed using the folder path and filename.
SuiteScript hooks are special hooks that can run within NetSuite on a RESTlet. They can leverage the full capabilities of SuiteScript for both imports and exports. SuiteScript hooks generally share the same contract as integrator.io hooks, mentioned here .
Can I use both a SuiteScript hook and an integrator.io script-based hook?
Yes, you can use both of these hooks in conjunction.
What SuiteScript versions are supported?
Currently, integrator.io supports and recommends hooks to be written in SuiteScript 2.0 because this is the latest SuiteScript major version. While integrator.io also supports SuiteScript 1.0, Netsuite is not making any updates to SuiteScript 1.0 and has recommended moving to SuiteScript 2.0. Note that your export, import, and hook should use the same SuiteScript version in flows. So check your export or import and write your hook using the appropriate NetSuite version.
Yes, you can use both of these hooks in conjunction. Depending on the Suitescript version and whether you have JavaScript hooks also configured, the workflow to process data is as follows:
Currently, the Celigo platform recommends writing SuiteScript 2.0 hooks because it is the latest SuiteScript major version. While the platform also supports SuiteScript 1.0, we recommend moving to SuiteScript 2.0 because NetSuite no longer updates SuiteScript 1.0.
Warning
Your NetSuite flow exports, imports, and hooks should use the same SuiteScript version. The pre map hook is not supported in Suite Script 2.0.
SuiteScript hooks run on RESTlets, so they follow the same NetSuite governance limits. This governance is shared with the Celigo platform execution as well, so make sure that you plan how many governance points (the number of API operations allowed) your hooks will consume.
What should I do:
-
If an import hook is invoked with one record, a NetSuite RESTlet has 5000 governance points, integrator.io will also consume points for all the lookups and creating/submitting the record in NetSuite.
-
If you are running out of points, try adjusting your flow slightly. For example, if you have complicated logic for your NetSuite import and your hooks are consuming a lot of points, you can reduce the pageSize of the corresponding export to have less data passed to the hook for each page.
-
In addition to the limits NetSuite puts on points (number of API operations allowed), it also puts a limit on execution time. Since a RESTlet has a 5-minute time limit, make sure that all the processing in your hooks is completed within that limit.
The Celigo platform allows you to attach a single file for a hook. You can build common libraries and closures into a single file to share common utils across hooks. To make it easier to write clean code, the Underscore.js JavaScript library is available when the hooks are invoked in NetSuite.
To view your export and import logs:
-
Navigate to ScriptPath → Customization → Scripting → Scripts → RESTlet:
-
Celigo IO Restlet Runner for SuiteApp SuiteScript 2.0.
-
Celigo SA Import Restlet Runner for SuiteApp SuiteScript 1.0.
-
Celigo Realtime Import Restlet Runner for the SuiteBundle SuiteScript 1.0.
-
To view real-time export logs:
-
Navigate to Customization → Scripting → Scripts:
-
Map/Reduce → Celigo Consumer Runner 2 for SuiteApp SuiteScript 2.0.
-
User Event → Celigo SS1.0 Presend Hook Processor for SuiteApp SuiteScript 1.0.
-
Scheduled → Celigo Consumer Runner for SuiteBundle SuiteScript 1.0.
-
Comments
0 comments
Article is closed for comments.