Configure onCpqDocumentCreate, onCpqDocumentUpdate, and onCpqDocumentDelete

onCpqDocumentCreate

The Configure, Price, Quote (CPQ) feature of Freshsales Suite enables organizations to configure and generate customer-specific quotes for products/services. As part of this feature, Freshsales Suite users can create standardized documents such as proposals, NDAs, MSAs, and so on by using pre-set templates. For more information, see CPQ add-on in Freshsales Suite.

The onCpqDocumentCreate event is triggered and the registered callback method is executed, when a new document is created in the Freshsales Suite system.

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

manifest.json
"events": {
  "onCpqDocumentCreate": {
    "handler": "onCpqDocumentCreateCallback"
  }
}

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

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

Attributes of the data object

  • actorobject

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

  • associationsobject

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

  • cpq_documentobject

    Information pertaining to the document that is created in the Freshsales Suite system.

onCpqDocumentUpdate

The onCpqDocumentUpdate event is triggered when,

  • The details of the document are updated.
  • The details of the products associated with the document are modified.
  • The document is previewed or saved as a PDF file.
  • The document is soft deleted.

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

manifest.json
"events": {
  "onCpqDocumentUpdate": {
    "handler": "onCpqDocumentUpdateCallback"
  }
}

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

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

Attributes of the data object

  • actorobject

    Information pertaining to the entity who triggered the onCpqDocumentUpdate event in the Freshales system.

  • associationsobject

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

  • changesobject

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

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

    Example

    {
      "model_changes": {
        "deal_id": [
          6796197,
          6891801
        ],
        "sales_account_id": [
          5135558,
          5212715
        ],
        "base_currency_amount": [
          677,
          0
        ]
      }
      "system_changes": {},
      "misc_changes": {}
    }
  • cpq_documentobject

    Information pertaining to the document that is created in the Freshsales Suite system.

onCpqDocumentDelete

The onCpqDocumentDelete event is triggered and the registered callback method is executed, when a document is deleted from the Freshsales Suite system.

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

manifest.json
"events": {
  "onCpqDocumentDelete": {
    "handler": "onCpqDocumentDeleteCallback"
  }
}

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

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

Attributes of the data object

  • actorobject

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

  • cpq_documentobject

    Information pertaining to the document that is deleted from the Freshsales Suite system.