# Netsuite Webhook Setup

\**Note: Functionality is currently limited to Purchase Orders\**

1. **Create a Netsuite Integration in Violet**
   * Navigate to Violet and [set up a new Netsuite integration](/apps/n/netsuite.md).
2. **Create a Webhook in Violet**

   * Click your user profile picture in the bottom-left corner.
   * Go to the **Webhooks** page.

   <div align="left"><figure><img src="/files/6DjadYUbf5EfCuCbkTpq" alt=""><figcaption></figcaption></figure></div>

   * Click on <mark style="color:purple;">**+ CREATE WEBHOOK URL**</mark>
   * Select the Netsuite integration you created.
3. **Copy the Webhook URL**
   * Save the generated URL — **this will only display once**.
4. **Download and Update the Script**
   * Download the [Violet Netsuite Webhook Script](https://drive.google.com/file/d/1FHY3y0zU8uFZiu2VGhc6TxKGBiOZgSlg/view?usp=sharing).
   * Replace `[PASTE WEBHOOK URL GENERATED IN THE VIOLET WEBHOOKS TAB HERE]` with your Webhook URL.
5. **Upload Script to Netsuite**
   * Navigate in Netsuite to: `Customization → Scripting → Scripts → New`.
   * Upload the script and give it a name.
6. **Deploy the Script**
   * Under the **Deployments** tab:
     * Set **Applies To** → `Purchase Order`.
     * Set the deployment **Status** → `Released`.
   * Save the script.
7. **Set Audience**
   * Open the script deployment page.
   * Under **Audience**, select `All Employees`. This will ensure that the script runs on the appropriate create or edit actions regardless of which user takes the action.
8. **Verify Webhook Functionality**
   * The webhook should now fire events to Violet whenever a PO or PO line is created or edited.
   * **Note:** Deletes are not supported by Webhooks - they will be reflect on the next scheduled fetch from Netsuite.
9. **Test Webhook Functionality**
   * Edit a Purchase Order within Netsuite, and change the location of the Purchase Order.
   * Within Violet, go into the integration timeline on your Netsuite integration (under `Apps → [Your Netsuite Integration Name] → Click the Timeline icon labeled "View Integration Timeline”`)
   * Check and see if you see a `webhook event` within the timeline, near the top.
   * Check and see if the changed location updates within the corresponding entity in Violet. This may take a few minutes to process.
   * If any of these steps do not work, contact Violet.

### Possible Errors

* **Error on saving edited PO:**

  ```
  Error
  An unexpected error has occurred. Please click here to notify support and provide your contact information.
  ```

  * Cause: Script deployment in Netsuite is not working correctly.
  * Solution: Delete the deployment and script, then start over from step 5. If the issue persists, contact Violet.
* **Changes not showing in Violet (no error on save):**
  * Check the Netsuite script execution log for errors sending the webhook.
  * Check the integration timeline (under `Apps → [Your Netsuite Integration Name] → Click the Timeline icon labeled "View Integration Timeline”`) in Violet for processing errors.
  * Contact Violet with the collected information.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.violetlabs.com/apps/n/netsuite/netsuite-webhook-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
