Configure onProductCreate and onProductUpdate

onProductCreate

When a product is created in the Freshsales Suite system, the onProductCreate is invoked and the registered callback method is executed.

Subscribe to the onProductCreate event and register the callback by using the following sample manifest.json content.

manifest.json
"events": {
  "onProductCreate": {
    "handler": "onProductCreateCallback"
  }
}

Define the corresponding callback by using the following sample server.js content:

server.js
exports = {
  onProductCreateCallback: function(payload) {
   console.log("Logging arguments from onProductCreate event: " + JSON.stringify(payload));
  }
}

Attributes of the data object

  • actorobject

    Information pertaining to the entity who triggered the onProductCreate event in the Freshsales Suite system.

  • associationsobject

    All associated objects of the product object, which specify additional information pertaining to the product created.

  • productobject

    Information pertaining to the product created in the Freshsales Suite system.

onProductUpdate

The onProductUpdate event is triggered when,

  • A product’s details are modified.
  • A product is soft deleted.
  • A product’s pricing details are modified.

Subscribe to the onProductUpdate event and register the callback by using the following sample manifest.json content.

manifest.json
"events": {
  "onProductUpdate": {
    "handler": "onProductUpdateCallback"
  }
}

Define the corresponding callback by using the following sample server.js content:

server.js
exports = {
  onProductUpdateCallback: function(payload) {
    console.log("Logging arguments from onProductUpdate event: " + JSON.stringify(payload));
  }
}

Attributes of the data object

  • actorobject

    Information pertaining to the entity who triggered the onProductUpdate event in the Freshsales Suite system.

  • associationsobject

    All associated objects of the product object, which specify additional information pertaining to the product updated.

  • changesobject

    Changes that triggered the onCpqDocumentUpdate event, specified as a JSON object of the following format:

    "changes": {
      "model_changes": {
        //For non-array attributes
        "<product.attribute that changed>": ["New value", "Old value"]
      },
      "system_changes": {},
      "misc_changes": {}
    }

    Example

    "changes": {
      "model_changes": {
        "name": [
          "Samsung",
          "Apple"
        ],
        "product_code": [
          "S11",
          "A01"
        ],
        "sku_number": [
          "MOSA12309",
          "A12309"
        ]
      },
      "system_changes": {},
      "misc_changes": {}
    }
  • productobject

    Information pertaining to the product created in the Freshsales Suite system.