Configure onDocumentUpdate

onDocumentUpdate

A document can be generated from a document template, enabling a ticket to share data or to submit a ticket workflow. The workflows can have information such as an agreement or approval note. After a template is linked to a service request item, each ticket created from that item has the option to generate a document, which is automatically filled with the ticket’s data. To learn more, see Document generation for employee requests.

The onDocumentUpdate event is triggered in the Freshworks system in the following scenarios:

  • A document is generated for a ticket
  • When a signer is requested to sign an e-sign document.
  • When a signer signs an e-sign document.
  • After all signers have signed the document and a document is generated.

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

manifest.json
"events": {
  "onDocumentUpdate": {
      "handler": "onDocumentUpdateCallback"
  }
}

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

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

Attributes of the data object

  • actorobject

    Information pertaining to the system, agent, or requester who triggered the onDocumentUpdate event in the Freshservice system.

  • associationsobject

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

  • changesobject

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

    "changes": {
     //For non-array attributes
     "<document.attribute that changed>": ["Old value", "New value"]
    }
    
  • documentobject

    Information pertaining to the document updated.