Skip to content

Plenty Article Create on Change

This Google Apps Script automates the creation of articles in PlentyMarkets when a specific trigger phrase is entered into a Google Sheet.

Overview

  • Script Name: Plenty_article_create_on_change.gs
  • Trigger: Edit event in the spreadsheet.
  • Trigger Column: Column N (Index 14).
  • Trigger Phrase: "Plenty anlegen" (case-insensitive, spaces ignored).
  • Target API: https://dashboard.lage-beauty.de/plenty/articles/create/article

How it Works

  1. Event Detection: The script listens for an "On edit" event.
  2. Validation:
    • Checks if the edit occurred in the correct column (Column N).
    • Checks if the entered value matches "Plenty anlegen".
  3. Data Collection:
    • Retrieves the entire row of data where the edit occurred.
    • Maps the row values to the header names (first row) to create a data object.
  4. API Request:
    • Sends a POST request to the configured API endpoint.
    • Payload includes the spreadsheet ID, sheet ID, row index, and the row data.
  5. Feedback:
    • Updates the cell to "Plenty angelegt" on success.
    • Updates the cell to "API error" or "script error" on failure.
    • Shows a toast notification in the spreadsheet UI.

Configuration

  • API URL: Currently set to https://dashboard.lage-beauty.de/plenty/articles/create/article.
  • Token: Uses a hardcoded token for authentication with the API.

Usage

To trigger the script:

  1. Fill in the article details in a row.
  2. In Column N of that row, type "Plenty anlegen".
  3. Wait for the cell to update to "Plenty angelegt".