Thanks to visit codestin.com
Credit goes to github.com

Skip to content

abhijeetdhara/monoSheet

Repository files navigation

monoSheet [Public Beta]

monoSheet

Under major changes

Recently I got to know about the policies enforced by my employer about the IP, techincally I do not own the IP of this project although I'd still be the author of this project. I got some good insights on the security side due to employer's involvement into monoSheet.

Please note that this still remains to be an open source project under the MIT license, as to respect the IP ownership I'll update the license agreement in a few days.


Future updates in pipeline

  1. "Me" filter for saved search filter baked into the integration.
  2. Support for OAuth 1.0a
  3. Support for OAuth 2.0 [Algos other than RSA] ✅

Overview

monoSheet provides a comprehensive solution to integrate NetSuite with Google Sheets using Google Apps Script and NetSuite RESTlet scripts. It enables users to fetch datasets and saved searches from NetSuite and populate them directly into Google Sheets for analysis and reporting. The solution leverages OAuth 2.0 authentication with JWT tokens for secure data transfer and includes caching mechanisms for optimized performance. A user-friendly HTML interface is provided for easy configuration of NetSuite credentials and report mappings.


Table of Contents

  1. Previous Version Demo
  2. Prerequisites
  3. Repository Structure
  4. Setup and Configuration
  5. Key Components
  6. OAuth Scopes
  7. Error Handling
  8. Google Secret Manager Configuration
  9. Third-Party Libraries
  10. Key Changes

Previous Version Demo

Watch the video


Prerequisites

  1. NetSuite Setup:

    • Ensure NetSuite RESTlet scripts are deployed and accessible.
    • Obtain the following credentials:
      • NetSuite Account ID
      • OAuth 2.0 Client ID and Private Key
      • Certificate ID (KID)
      • Google Secret Manager project ID and secret details
  2. Google Cloud Setup:

    • Configure Google Secret Manager with NetSuite credentials.
  3. Google Sheets Setup:

    • Open a Google Sheet and add the provided script & HTML to the Apps Script editor.

Repository Structure

.
├── Appscript Files
│   ├── README.md
│   ├── appScriptGSheetDataPull.gs
│   ├── jrassign-all-min 11.1.0.js
│   └── nsUiConfig.html
├── SuiteScript Files
│   ├── README.md
│   ├── RS_getDataset.js
│   └── RS_getDatasetMetadata.js
├── README.md
└── LICENSE
  • Appscript Files/: Contains the Google Apps Script code for integration and the HTML configuration interface.
  • SuiteScript Files/: Contains the NetSuite RESTlet scripts for metadata retrieval and data fetching.
  • README.md: Documentation for setting up and using the integration.
  • LICENSE: License information for the repository.

Setup and Configuration

NetSuite Setup

  1. Deploy the provided RESTlet scripts in NetSuite:

    • RS_getDatasetMetadata.js: Fetches metadata about datasets and saved searches.
    • RS_getDataset.js: Retrieves data from datasets and saved searches.
  2. Obtain the required OAuth credentials from your NetSuite account settings.

Google Cloud Setup

  1. Configure Google Secret Manager to store NetSuite credentials in the specified format.

Google Sheets Setup

  1. Open the Script Editor (Extensions > Apps Script) in your Google Sheet.
  2. Copy and paste the contents of appScriptGSheetDataPull.gs into the script editor.
  3. Add nsUiConfig.html as a new HTML file in the script editor.
  4. Add two parameters - 'menuData' & 'nsConfig' to the script properties.
  5. Save and close the script editor.

Key Components

Google Apps Script

  • appScriptGSheetDataPull.gs: Handles authentication, data fetching, caching, and UI generation within Google Sheets.
  • Functions:
    • onOpen(): Initializes the custom menu in Google Sheets.
    • showConfigurationDialog(): Opens the configuration UI.
    • getAccessTokenCached(): Manages OAuth token retrieval and caching.
    • getData(): Fetches data from NetSuite and publishes it to Google Sheets.

NetSuite RESTlet Scripts

  • RS_getDatasetMetadata.js: Retrieves metadata about datasets and saved searches.
  • RS_getDataset.js: Fetches actual data from NetSuite based on user-defined parameters.

HTML Interface

  • nsUiConfig.html: Provides a graphical interface for configuring NetSuite credentials and report mappings.
    • Functions:
      • populateSecrets(data): Populates the secret configuration form.

      • populateReportMapping(data): Displays report mapping configurations.

      • saveSecrets() / saveMapping(): Saves configurations to script properties.

        image


OAuth Scopes

Ensure the following OAuth scopes are enabled for the script to function correctly:

"oauthScopes": [
  "https://www.googleapis.com/auth/script.external_request",
  "https://www.googleapis.com/auth/cloud-platform",
  "https://www.googleapis.com/auth/spreadsheets.currentonly",
  "https://www.googleapis.com/auth/userinfo.email",
  "https://www.googleapis.com/auth/script.container.ui"
]

Error Handling

  • Comprehensive try-catch blocks are implemented to handle potential errors.
  • Errors from NetSuite API and Google Secret Manager are logged using Logger.log and displayed via ui.alert.

Google Secret Manager Configuration

Ensure your Google Secret Manager stores the NetSuite configuration in the following JSON format:

{
  "pagestoload": "5",    // Minimum-0, Maximum-anything that restlet can handle within governance, but do note higher number = higher API response time
  "metadatascriptid": "NSMETADATASCRIPTID",
  "metadatadeployid": "NSMETADATASCRIPTDEPLOYID",
  "reportscriptid": "NSREPORTSCRIPTID",
  "reportdeployid": "NSREPORTSCRIPTDEPLOYID",
  "kid": "OAUTH2_CERTIFICATE_ID",
  "clientid": "CLIENT_ID",
  "privatekey": "PRIVATE_CERTIFICATE"
}

Third-Party Libraries

This repository is licensed under the MIT License and uses the following third-party libraries:


Key Changes:

  • [21/01/2025]
    • Added folders to maintain files hierarchy.
    • Added a "Third-Party Libraries" section to acknowledge the use of the MIT-licensed library.
    • Maintained the structure and clarity of README.md.
  • [01/02/2025]
    • Added support for Saved Searches.
    • Added support for Report grouping - allows users to group multiple reports so that they can be loaded in a single click.
    • Added UI config page to setup your integration and report mappings.
    • Added technical docs to each folders.
  • [02/02/2025]
    • Added the missing script properties for the appscript.
  • [04/02/2025]
    • Added the previous version demo.

About

Contains the project files for the monoSheet

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published