FileSync API for SuiteScript

Available since version 0.5.0

API Overview 

The FileSync API for SuiteScript is a module which can be loaded into local scripts to interact with the FileSync bundle and trigger changes in the external file hosting solution via the integration. This includes features such as uploading files, getting a list of folder content and retrieving individual file contents.

Script Types and Version Compatibility 

The SuiteScript API is intended to be used with server-side script types and does not support Client Scripts running in the browser. 

The module has been written in SuiteScript 2.1 and so scripts which utilize the module must also be written in SuiteScript 2.1. Scripts written in SuiteScript 2.0 may appear to load the module but errors will occur when attempting to run scripts. 

The following script types are all supported:

  • User Event Scripts
  • Suitelets (back-end processing, not operations directly on the form in-browser)
  • Map/Reduce Scripts
  • Scheduled Scripts
  • Custom Workflow Actions
  • RESTlet Scripts

Loading the Module

The FileSync SuiteScript API module can be loaded directly in the "define" call of SuiteScript 2.1 scripts. The following is an example of this. Examples of how to use various function calls are listed under the documentation for each.

/**
 * Example User Event script utilizing the FileSync SuiteScript API Module
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define(["N/record","N/search", "/SuiteApps/com.scscloud.files/suitescript/b4cd-fileapi-lib"], function(record, search, fileapi) {

    function afterSubmit(context) {
        //Custom logic implemented here
    }

    return {
        afterSubmit
    }

})

Available Functions

The currently published functions for the FileSync SuiteScript API are published here: Available Functions

Connections & Configurations

The functions available in the API all depend on the SuperSync Files Connection and Record Type Configuration records which can be setup under the SuperSync Files > Configs menu in NetSuite. 

Note that if connections are setup pointing to a production Sharepoint or Google Drive environment, calls via the API module will connect to the same environment as configured, thus it is wise to test any scripts developed on a NetSuite Sandbox account with SuperSync Files Connection records setup pointing to test sites or test drives first. 


Referencing Record Type Configuration IDs

Due to the fact that multiple record type configuration records can be setup for one given record type (e.g. multiple configuration records for invoices or vendors etc) the most of the API functions require that recordTypeConfigId parameters are passed so that there is no ambiguity and the correct settings are utilized for each call. 

To avoid "hard-coding" configuration internal IDs into scripts, it is recommended that a reference code is populated on the record type configuration ID in NetSuite which can then be used to retrieve the internal ID of the configuration in the code. 

To populate this reference code, navigate to the record type configuration record under SuperSync Files > Configs > Record Type Configs. The reference code can be found under the Other Settings tab. 


This reference code has no use other than referencing the record via scripts. Care should be taken not to populate two record type configurations with the same config ID. 

In SuiteScript the getConfigList call can be used to retrieve a list of all configs including the reference code and the recordTypeConfigId which can then be used in subsequent requests. 


Was this article helpful?